Пример #1
0
 /**
  * Attempt to login the specified user.
  *
  * @return \Illuminate\Http\Response
  */
 public function postLogin()
 {
     $remember = Binput::get('rememberMe');
     $input = Binput::only(['email', 'password']);
     $rules = UserRepository::rules(array_keys($input));
     $rules['password'] = '******';
     $val = UserRepository::validate($input, $rules, true);
     if ($val->fails()) {
         return Redirect::route('account.login')->withInput()->withErrors($val->errors());
     }
     $this->throttler->hit();
     try {
         $throttle = Credentials::getThrottleProvider()->findByUserLogin($input['email']);
         $throttle->check();
         Credentials::authenticate($input, $remember);
     } catch (WrongPasswordException $e) {
         return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', 'Your password was incorrect.');
     } catch (UserNotFoundException $e) {
         return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', 'That user does not exist.');
     } catch (UserNotActivatedException $e) {
         if (Config::get('credentials::activation')) {
             return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', 'You have not yet activated this account.');
         } else {
             $throttle->user->attemptActivation($throttle->user->getActivationCode());
             $throttle->user->addGroup(Credentials::getGroupProvider()->findByName('Users'));
             return $this->postLogin();
         }
     } catch (UserSuspendedException $e) {
         $time = $throttle->getSuspensionTime();
         return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', "Your account has been suspended for {$time} minutes.");
     } catch (UserBannedException $e) {
         return Redirect::route('account.login')->withInput()->withErrors($val->errors())->with('error', 'You have been banned. Please contact support.');
     }
     return Redirect::intended(Config::get('core.home', '/'));
 }
 /**
  * Updates the status page settings.
  *
  * @return \Illuminate\View\View
  */
 public function postSettings()
 {
     if (Binput::get('remove_banner') == "1") {
         $setting = Setting::where('name', 'app_banner');
         $setting->delete();
     }
     if (Binput::hasFile('app_banner')) {
         $file = Binput::file('app_banner');
         // Image Validation.
         // Image size in bytes.
         $maxSize = $file->getMaxFilesize();
         if ($file->getSize() > $maxSize) {
             return Redirect::back()->withErrorMessage("You need to upload an image that is less than {$maxSize}.");
         }
         if (!$file->isValid() || $file->getError()) {
             return Redirect::back()->withErrorMessage($file->getErrorMessage());
         }
         if (strpos($file->getMimeType(), 'image/') !== 0) {
             return Redirect::back()->withErrorMessage('Only images may be uploaded.');
         }
         // Store the banner.
         Setting::firstOrCreate(['name' => 'app_banner'])->update(['value' => base64_encode(file_get_contents($file->getRealPath()))]);
         // Store the banner type
         Setting::firstOrCreate(['name' => 'app_banner_type'])->update(['value' => $file->getMimeType()]);
     }
     try {
         foreach (Binput::except(['app_banner', 'remove_banner']) as $settingName => $settingValue) {
             Setting::firstOrCreate(['name' => $settingName])->update(['value' => $settingValue]);
         }
     } catch (Exception $e) {
         return Redirect::back()->withSaved(false);
     }
     return Redirect::back()->withSaved(true);
 }
Пример #3
0
 /**
  * Updates the order of project teams.
  *
  * @return array
  */
 public function postUpdateProjectTeamOrder()
 {
     $teamData = Binput::get('ids');
     foreach ($teamData as $order => $teamId) {
         ProjectTeam::find($teamId)->update(['order' => $order + 1]);
     }
     return $teamData;
 }
Пример #4
0
 /**
  * Returns a template by slug.
  *
  * @throws \Illuminate\Database\Eloquent\ModelNotFoundException
  *
  * @return \CachetHQ\Cachet\Models\IncidentTemplate
  */
 public function getIncidentTemplate()
 {
     $templateSlug = Binput::get('slug');
     if ($template = IncidentTemplate::where('slug', $templateSlug)->first()) {
         return $template;
     }
     throw new ModelNotFoundException("Incident template for {$templateSlug} could not be found.");
 }
Пример #5
0
 /**
  * Update an existing team.
  *
  * @param \Gitamin\Models\ProjectTeam $team
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function putTeam(ProjectTeam $team)
 {
     try {
         $team = $this->dispatch(new UpdateProjectTeamCommand($team, Binput::get('name'), Binput::get('slug'), Binput::get('order', 0)));
     } catch (QueryException $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($team);
 }
Пример #6
0
 /**
  * Update an existing issue.
  *
  * @param \Gitamin\Models\Inicdent $issue
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function putIssue(Issue $issue)
 {
     try {
         $issue = $this->dispatch(new UpdateIssueCommand($issue, Binput::get('name'), Binput::get('status'), Binput::get('message'), Binput::get('visible', true), Binput::get('user_id'), Binput::get('project_id'), Binput::get('notify', true), Binput::get('created_at')));
     } catch (QueryException $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($issue);
 }
Пример #7
0
 /**
  * Create a new component group.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function postGroups()
 {
     try {
         $group = $this->dispatch(new AddComponentGroupCommand(Binput::get('name'), Binput::get('order', 0)));
     } catch (Exception $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($group);
 }
Пример #8
0
 /**
  * Create a new metric point.
  *
  * @param \CachetHQ\Cachet\Models\Metric $metric
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function postMetricPoints(Metric $metric)
 {
     try {
         $metricPoint = $this->dispatch(new AddMetricPointCommand($metric, Binput::get('value'), Binput::get('timestamp')));
     } catch (Exception $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($metricPoint);
 }
Пример #9
0
 /**
  * Handle the subscribe user.
  *
  * @return \Illuminate\View\View
  */
 public function postSubscribe()
 {
     try {
         $this->dispatch(new SubscribeSubscriberCommand(Binput::get('email')));
     } catch (ValidationException $e) {
         return Redirect::route('subscribe.subscribe')->withInput(Binput::all())->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('gitamin.subscriber.email.failure')))->withErrors($e->getMessageBag());
     }
     return Redirect::route('explore')->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('gitamin.subscriber.email.subscribed')));
 }
Пример #10
0
 /**
  * Creates a new subscriber.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function createSubscriberAction()
 {
     try {
         dispatch(new SubscribeSubscriberCommand(Binput::get('email')));
     } catch (ValidationException $e) {
         return Redirect::route('dashboard.subscribers.add')->withInput(Binput::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))->withErrors($e->getMessageBag());
     }
     return Redirect::route('dashboard.subscribers.add')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')));
 }
Пример #11
0
 /**
  * Create a new incident.
  *
  * @param \Illuminate\Contracts\Auth\Guard $auth
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function postIncidents(Guard $auth)
 {
     try {
         $incident = $this->dispatch(new ReportIncidentCommand(Binput::get('name'), Binput::get('status'), Binput::get('message'), Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', true)));
     } catch (Exception $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($incident);
 }
Пример #12
0
 /**
  * Create a new subscriber.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function postSubscribers()
 {
     try {
         $subscriber = $this->dispatch(new SubscribeSubscriberCommand(Binput::get('email'), Binput::get('verify', false)));
     } catch (QueryException $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($subscriber);
 }
Пример #13
0
 /**
  * Update an existing metric.
  *
  * @param \CachetHQ\Cachet\Models\Metric $metric
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function putMetric(Metric $metric)
 {
     try {
         $metric = $this->dispatch(new UpdateMetricCommand($metric, Binput::get('name'), Binput::get('suffix'), Binput::get('description'), Binput::get('default_value'), Binput::get('calc_type', 0), Binput::get('display_chart'), Binput::get('places', 2)));
     } catch (Exception $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($metric);
 }
Пример #14
0
 /**
  * Update an existing group.
  *
  * @param \CachetHQ\Cachet\Models\ComponentGroup $group
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function putGroup(ComponentGroup $group)
 {
     try {
         $group = $this->dispatch(new UpdateComponentGroupCommand($group, Binput::get('name'), Binput::get('order', 0)));
     } catch (QueryException $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($group);
 }
Пример #15
0
 /**
  * Update an existing metric.
  *
  * @param \CachetHQ\Cachet\Models\Metric $metric
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function putMetric(Metric $metric)
 {
     try {
         $metric = dispatch(new UpdateMetricCommand($metric, Binput::get('name'), Binput::get('suffix'), Binput::get('description'), Binput::get('default_value'), Binput::get('calc_type'), Binput::get('display_chart'), Binput::get('places'), Binput::get('default_view', Binput::get('view')), Binput::get('threshold'), Binput::get('order')));
     } catch (QueryException $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($metric);
 }
Пример #16
0
 /**
  * Creates a new team member.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function postAddUser()
 {
     try {
         $this->dispatch(new AddTeamMemberCommand(Binput::get('username'), Binput::get('password'), Binput::get('email'), Binput::get('level')));
     } catch (ValidationException $e) {
         return Redirect::route('dashboard.team.add')->withInput(Binput::except('password'))->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.team.add.failure')))->withErrors($e->getMessageBag());
     }
     return Redirect::route('dashboard.team.add')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.team.add.success')));
 }
Пример #17
0
 /**
  * Update an existing incident.
  *
  * @param \CachetHQ\Cachet\Models\Inicdent $incident
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function putIncident(Incident $incident)
 {
     try {
         $incident = $this->dispatch(new UpdateIncidentCommand($incident, Binput::get('name'), Binput::get('status'), Binput::get('message'), Binput::get('visible', true), Binput::get('component_id'), Binput::get('component_status'), Binput::get('notify', true), Binput::get('created_at'), Binput::get('template'), Binput::get('vars')));
     } catch (Exception $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($incident);
 }
Пример #18
0
 /**
  * Create a new subscriber.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function postSubscribers()
 {
     $verified = Binput::get('verify', app(Repository::class)->get('setting.skip_subscriber_verification'));
     try {
         $subscriber = dispatch(new SubscribeSubscriberCommand(Binput::get('email'), $verified, Binput::get('components')));
     } catch (QueryException $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($subscriber);
 }
Пример #19
0
 /**
  * Handle the subscribe user.
  *
  * @return \Illuminate\View\View
  */
 public function postSubscribe()
 {
     try {
         $subscriber = Subscriber::create(['email' => Binput::get('email')]);
     } catch (ValidationException $e) {
         return Redirect::route('subscribe.subscribe')->withInput(Binput::all())->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))->withErrors($e->getMessageBag());
     }
     event(new CustomerHasSubscribedEvent($subscriber));
     return Redirect::route('status-page')->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed')));
 }
Пример #20
0
 /**
  * Handle the subscribe user.
  *
  * @return \Illuminate\View\View
  */
 public function postSubscribe()
 {
     $subscriber = Subscriber::create(['email' => Binput::get('email')]);
     if (!$subscriber->isValid()) {
         return Redirect::back()->withInput(Binput::all())->with('title', sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))->with('errors', $subscriber->getErrors());
     }
     $successMsg = sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed'));
     event(new CustomerHasSubscribedEvent($subscriber));
     return Redirect::route('status-page')->with('success', $successMsg);
 }
Пример #21
0
 /**
  * Update an existing group.
  *
  * @param \CachetHQ\Cachet\Models\ComponentGroup $group
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function putGroup(ComponentGroup $group)
 {
     $groupData = array_filter(Binput::only(['name', 'order']));
     try {
         $group = $this->dispatch(new UpdateComponentGroupCommand($group, Binput::get('name'), Binput::get('order', 0)));
     } catch (Exception $e) {
         throw new BadRequestHttpException();
     }
     return $this->item($group);
 }
Пример #22
0
 /**
  * Creates a new subscriber.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function createSubscriberAction()
 {
     $email = Binput::get('email');
     try {
         $subscriber = Subscriber::create(['email' => $email]);
     } catch (ValidationException $e) {
         return Redirect::route('dashboard.subscribers.add')->withInput(Binput::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))->withErrors($e->getMessageBag());
     }
     event(new CustomerHasSubscribedEvent($subscriber));
     return Redirect::route('dashboard.subscribers.add')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')));
 }
Пример #23
0
 /**
  * Creates a new subscriber.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function createSubscriberAction()
 {
     $email = Binput::get('email');
     $subscriber = Subscriber::create(['email' => $email]);
     if (!$subscriber->isValid()) {
         return Redirect::back()->withInput(Binput::all())->with('title', sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))->with('errors', $subscriber->getErrors());
     }
     $successMsg = sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success'));
     event(new CustomerHasSubscribedEvent($subscriber));
     return Redirect::back()->with('success', $successMsg);
 }
Пример #24
0
 /**
  * Handle the subscribe user.
  *
  * @return \Illuminate\View\View
  */
 public function postSubscribe()
 {
     $email = Binput::get('email');
     try {
         dispatch(new SubscribeSubscriberCommand($email));
     } catch (AlreadySubscribedException $e) {
         return Redirect::route('subscribe.subscribe')->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))->withErrors(trans('cachet.subscriber.email.already-subscribed', ['email' => $email]));
     } catch (ValidationException $e) {
         return Redirect::route('subscribe.subscribe')->withInput(Binput::all())->withTitle(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.whoops'), trans('cachet.subscriber.email.failure')))->withErrors($e->getMessageBag());
     }
     return Redirect::route('status-page')->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.subscriber.email.subscribed')));
 }
Пример #25
0
 /**
  * Creates a new subscriber.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function createSubscriberAction()
 {
     $verified = app(Repository::class)->get('setting.skip_subscriber_verification');
     try {
         $subscribers = preg_split("/\r\n|\n|\r/", Binput::get('email'));
         foreach ($subscribers as $subscriber) {
             dispatch(new SubscribeSubscriberCommand($subscriber, $verified));
         }
     } catch (ValidationException $e) {
         return Redirect::route('dashboard.subscribers.add')->withInput(Binput::all())->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('dashboard.subscribers.add.failure')))->withErrors($e->getMessageBag());
     }
     return Redirect::route('dashboard.subscribers.add')->withSuccess(sprintf('%s %s', trans('dashboard.notifications.awesome'), trans('dashboard.subscribers.add.success')));
 }
Пример #26
0
 /**
  * Create a new subscriber.
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function postSubscribers()
 {
     $subscriberData = Binput::except('verify');
     try {
         $subscriber = Subscriber::create($subscriberData);
     } catch (Exception $e) {
         throw new BadRequestHttpException();
     }
     // If we're auto-verifying the subscriber, don't bother with this event.
     if (!Binput::get('verify')) {
         event(new CustomerHasSubscribedEvent($subscriber));
     }
     return $this->item($subscriber);
 }
Пример #27
0
 /**
  * Returns the rendered Blade templates.
  *
  * @return \Illuminate\View\View
  */
 public function showIndex()
 {
     $today = Date::now();
     $startDate = Date::now();
     segment_page('Status Page');
     // Check if we have another starting date
     if (Binput::has('start_date')) {
         try {
             // If date provided is valid
             $oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
             segment_track('Status Page', ['start_date' => $oldDate->format('Y-m-d')]);
             // If trying to get a future date fallback to today
             if ($today->gt($oldDate)) {
                 $startDate = $oldDate;
             }
         } catch (Exception $e) {
             // Fallback to today
         }
     }
     $metrics = null;
     if ($displayMetrics = Setting::get('display_graphs')) {
         $metrics = Metric::where('display_chart', 1)->get();
     }
     $daysToShow = Setting::get('app_incident_days') ?: 7;
     $incidentDays = range(0, $daysToShow - 1);
     $dateTimeZone = Setting::get('app_timezone');
     $incidentVisiblity = Auth::check() ? 0 : 1;
     $allIncidents = Incident::notScheduled()->where('visible', '>=', $incidentVisiblity)->whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('created_at', 'desc')->get()->groupBy(function (Incident $incident) use($dateTimeZone) {
         return (new Date($incident->created_at))->setTimezone($dateTimeZone)->toDateString();
     });
     // Add in days that have no incidents
     foreach ($incidentDays as $i) {
         $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
         if (!isset($allIncidents[$date->toDateString()])) {
             $allIncidents[$date->toDateString()] = [];
         }
     }
     // Sort the array so it takes into account the added days
     $allIncidents = $allIncidents->sortBy(function ($value, $key) {
         return strtotime($key);
     }, SORT_REGULAR, true)->all();
     // Scheduled maintenance code.
     $scheduledMaintenance = Incident::scheduled()->orderBy('scheduled_at')->get();
     // Component & Component Group lists.
     $usedComponentGroups = Component::where('group_id', '>', 0)->groupBy('group_id')->lists('group_id');
     $componentGroups = ComponentGroup::whereIn('id', $usedComponentGroups)->orderBy('order')->get();
     $ungroupedComponents = Component::where('group_id', 0)->orderBy('order')->orderBy('created_at')->get();
     $canPageBackward = Incident::notScheduled()->where('created_at', '<', $startDate->format('Y-m-d'))->count() != 0;
     return View::make('index', ['componentGroups' => $componentGroups, 'ungroupedComponents' => $ungroupedComponents, 'displayMetrics' => $displayMetrics, 'metrics' => $metrics, 'allIncidents' => $allIncidents, 'scheduledMaintenance' => $scheduledMaintenance, 'aboutApp' => Markdown::convertToHtml(Setting::get('app_about')), 'canPageForward' => (bool) $today->gt($startDate), 'canPageBackward' => $canPageBackward, 'previousDate' => $startDate->copy()->subDays($daysToShow)->toDateString(), 'nextDate' => $startDate->copy()->addDays($daysToShow)->toDateString(), 'pageTitle' => Setting::get('app_name') . ' Status']);
 }
Пример #28
0
 /**
  * Displays the explore page.
  *
  * @return \Illuminate\View\View
  */
 public function showIndex()
 {
     $today = Date::now();
     $startDate = Date::now();
     // Check if we have another starting date
     if (Binput::has('start_date')) {
         try {
             // If date provided is valid
             $oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
             // If trying to get a future date fallback to today
             if ($today->gt($oldDate)) {
                 $startDate = $oldDate;
             }
         } catch (Exception $e) {
             // Fallback to today
         }
     }
     $daysToShow = Setting::get('app_issue_days', 0) - 1;
     if ($daysToShow < 0) {
         $daysToShow = 0;
         $issueDays = [];
     } else {
         $issueDays = range(0, $daysToShow);
     }
     $dateTimeZone = Setting::get('app_timezone');
     $issueVisiblity = Auth::check() ? 0 : 1;
     $allIssues = Issue::where('visible', '>=', $issueVisiblity)->whereBetween('created_at', [$startDate->copy()->subDays($daysToShow)->format('Y-m-d') . ' 00:00:00', $startDate->format('Y-m-d') . ' 23:59:59'])->orderBy('scheduled_at', 'desc')->orderBy('created_at', 'desc')->get()->groupBy(function (Issue $issue) use($dateTimeZone) {
         // If it's scheduled, get the scheduled at date.
         if ($issue->is_scheduled) {
             return (new Date($issue->scheduled_at))->setTimezone($dateTimeZone)->toDateString();
         }
         return (new Date($issue->created_at))->setTimezone($dateTimeZone)->toDateString();
     });
     // Add in days that have no issues
     foreach ($issueDays as $i) {
         $date = (new Date($startDate))->setTimezone($dateTimeZone)->subDays($i);
         if (!isset($allIssues[$date->toDateString()])) {
             $allIssues[$date->toDateString()] = [];
         }
     }
     // Sort the array so it takes into account the added days
     $allIssues = $allIssues->sortBy(function ($value, $key) {
         return strtotime($key);
     }, SORT_REGULAR, true)->all();
     return View::make('index')->withDaysToShow($daysToShow)->withAllIssues($allIssues)->withCanPageForward((bool) $today->gt($startDate))->withCanPageBackward(Issue::where('created_at', '<', $startDate->format('Y-m-d'))->count() > 0)->withPreviousDate($startDate->copy()->subDays($daysToShow)->toDateString())->withNextDate($startDate->copy()->addDays($daysToShow)->toDateString());
 }
Пример #29
0
 /**
  * Update an existing component.
  *
  * @param \CachetHQ\Cachet\Models\Componet $component
  *
  * @return \CachetHQ\Cachet\Models\Component
  */
 public function putComponent(Component $component)
 {
     try {
         $component->update(Binput::except('tags'));
     } catch (Exception $e) {
         throw new BadRequestHttpException();
     }
     if (Binput::has('tags')) {
         $tags = preg_split('/ ?, ?/', Binput::get('tags'));
         // For every tag, do we need to create it?
         $componentTags = array_map(function ($taggable) use($component) {
             return Tag::firstOrCreate(['name' => $taggable])->id;
         }, $tags);
         $component->tags()->sync($componentTags);
     }
     return $this->item($component);
 }
Пример #30
0
 /**
  * Handle a signup request.
  *
  * @param string|null $code
  *
  * @return \Illuminate\View\View
  */
 public function postSignup($code = null)
 {
     if ($code === null) {
         throw new NotFoundHttpException();
     }
     $invite = Invite::where('code', '=', $code)->first();
     if (!$invite || $invite->is_claimed) {
         throw new BadRequestHttpException();
     }
     try {
         dispatch(new SignupUserCommand(Binput::get('username'), Binput::get('password'), Binput::get('email'), User::LEVEL_USER));
     } catch (ValidationException $e) {
         return Redirect::route('signup.invite', ['code' => $invite->code])->withInput(Binput::except('password'))->withTitle(sprintf('%s %s', trans('dashboard.notifications.whoops'), trans('cachet.signup.failure')))->withErrors($e->getMessageBag());
     }
     dispatch(new ClaimInviteCommand($invite));
     return Redirect::route('status-page')->withSuccess(sprintf('<strong>%s</strong> %s', trans('dashboard.notifications.awesome'), trans('cachet.signup.success')));
 }