/** * Execute the job. * * @param Mailer $mailer * @return void */ public function handle(Mailer $mailer) { Clockwork::startEvent('mail.account_created', 'Mail account created.'); $mailer->send('mails.accountCreated', ['username' => $this->user->username], function ($message) { $message->to($this->user->email, $this->user->username)->subject('Account created'); }); Clockwork::endEvent('mail.account_created'); }
/** * Execute the job. * * @param Mailer $mailer * @return void */ public function handle(Mailer $mailer) { Clockwork::startEvent('mail.lost_password', 'Mail account created.'); $mailer->send('mails.lostPassword', ['token' => $this->token, 'username' => $this->user->username], function ($message) { $message->to($this->user->email, $this->user->username)->subject('Lost password'); }); Clockwork::endEvent('mail.lost_password'); }
/** * EventsDataSource constructor. */ public function __construct() { $this->events = []; Event::listen('*', function ($param) { /** @todo fix that shit */ if (!class_exists('events')) { return; } $this->events[] = ['name' => Event::firing(), 'param' => json_encode($param), 'time' => microtime(true)]; $currentTime = microtime(true); Clockwork::addEvent(uniqid('event_'), Event::firing(), $currentTime, $currentTime); }); }
/** * @param $request * @param \Closure $next * @param array $permissions * * @see http://laravel.com/docs/5.1/middleware#middleware-parameters * * @return \Illuminate\Http\RedirectResponse|\Laravel\Lumen\Http\Redirector */ public function handle($request, Closure $next, $permissions = []) { if (!is_array($permissions)) { $permissions = [$permissions]; } // no permission required if (empty($permissions)) { return $next($request); } Clockwork::startEvent('acl.middleware', 'Acl middleware.'); foreach ($permissions as $permission) { if (!Acl::isUserAllow(Auth::user(), $permission)) { Clockwork::stopEvent('acl.middleware'); if (Request::is('api*')) { return response('Not authorized', 403); } else { return view('auth.notAuthorized'); } } } Clockwork::stopEvent('acl.middleware'); return $next($request); }
/** * @param ValidationInterface $model * * @throws ModelNotValid */ protected function validate(ValidationInterface $model) { $timelineKey = uniqid('validation_'); Clockwork::startEvent($timelineKey, 'Validation of model ' . get_class($model)); $modelArray = $model->toArray(); // add hiddens fields to the array for validation foreach ($model->getHidden() as $hidden) { $modelArray[$hidden] = $model->{$hidden}; } $validator = Validator::make($modelArray, $model->getRules()); if ($validator->fails()) { Clockwork::endEvent($timelineKey); $model->setErrors($validator->errors()); throw new ModelNotValid($validator->errors()); } Clockwork::endEvent($timelineKey); }