/** * Handle the event. * * @param ChapterStatusChanged $event * @return void */ public function handle(ChapterStatusChanged $event) { $book = $event->chapter->book; if (Request::user()->isAuthor() && $event->chapter->status == 'drafted') { $data = ['chapter_title' => $event->chapter->title, 'chapter_id' => $event->chapter->id, 'book_title' => $book->title, 'book_id' => $book->id]; $this->sendEmailForDraftedChapter($data, $book); } elseif ((Request::user()->isAdmin() || Request::user()->isEditor()) && $event->chapter->status == 'published') { $event->chapter->update(['published_at' => Carbon::now()]); $emailsFollowersList = $this->userRepository->allFollowersForUser($book->author_id)->pluck('email')->toArray(); $data = ['chapter_title' => $event->chapter->title, 'chapter_id' => $event->chapter->id, 'book_title' => $book->title, 'book_id' => $book->id]; $this->sendEmailForPublishedChapter($data, $book, $emailsFollowersList); } }
/** * Bind data to the view. * * @param View $view * @return void */ public function compose(View $view) { // Are we connecting from a known URL? if ($airline = Airline::where('url', '=', Request::getHttpHost())->first()) { Session::put('airlineId', $airline->id); } if (Session::has('airlineId')) { $view->with('airline', Airline::find(Session::get('airlineId'))); } if (Request::user()) { $view->with('user', Request::user()); $view->with('pilot', PilotRepository::getCurrentPilot()); $airline = Airline::find(Session::get('airlineId')); $view->with('airlineStaff', UserRepository::hasRole($airline->prefix . '-staff', Request::user())); } }
public function index() { if (Request::input('l')) { LaravelLogViewer::setFile(base64_decode(Request::input('l'))); } if (Request::input('dl')) { Log::notice('perm.log.site.download - SiteLog downloaded', ['user_id' => Request::user()->user_id]); return Response::download(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('dl')))); } elseif (Request::has('del')) { File::delete(LaravelLogViewer::pathToLogFile(base64_decode(Request::input('del')))); Log::notice('perm.log.site.delete - SiteLog deleted', ['user_id' => Request::user()->user_id]); return Redirect::to(Request::url()); } $logs = LaravelLogViewer::all(); Log::notice('perm.log.site.view - SiteLog opened', ['user_id' => Request::user()->user_id]); return View::make('laravel-log-viewer::log', ['logs' => $logs, 'files' => LaravelLogViewer::getFiles(true), 'current_file' => LaravelLogViewer::getFileName()]); }
public static function getCurrentPilot() { return Pilot::where('user_id', '=', Request::user()->id)->where('airline_id', '=', Airline::find(Session::get('airlineId'))->id)->first(); }
/** * Attempt to find the user id of the currently logged in user. * * @return string|null */ private function getUserId() { if ($user = Request::user()) { return $user->user_id; } return null; }
/** * Update current user preferences. * * @return mixed */ public function updatePreferences(array $data) { $user = Request::user(); $user->preferences = array_merge((array) $user->preferences, $data); $user->save(); }