if (Sentry::check()) { $event_id = Request::segment(3); $event_author = ep\Event::find($event_id)->author_id; $current_user = Sentry::getUser(); if ($current_user->id == $event_author || $current_user->hasAccess('admin')) { } else { return Redirect::to('/')->with('global_error', 'This is restricted area. You shall not pass.'); } } else { return Redirect::guest('login'); } }); Route::filter('authorShow', function () { if (Sentry::check()) { $show_id = Request::segment(3); $show_author = Show::find($show_id)->author_id; $current_user = Sentry::getUser(); if ($current_user->id == $show_author || $current_user->hasAccess('admin')) { } else { return Redirect::to('/')->with('global_error', 'This is restricted area. You shall not pass.'); } } else { return Redirect::guest('login'); } }); /* |-------------------------------------------------------------------------- | Cache |-------------------------------------------------------------------------- | | Caches current route. Don't use with hello view, it has custom cache per user.
public function unfavourite($id) { $user = Sentry::getUser(); $show = Show::find($id); $fav_check = $show->showUser()->where('user_id', '=', $user->id)->first(); if ($fav_check == false) { return Redirect::to(URL::to('/'))->with('global_error', 'This show doesn\'t exists in your favourites.'); } else { $show->showUser()->detach($user); return Redirect::to(URL::previous())->with('global_success', 'Show has been removed from favourites.'); } }