示例#1
0
 /**
  * Dashboard for user's content management, only for auth user.
  */
 public function dashboard()
 {
     $user = Sentry::getUser();
     $added_events = ep\Event::where('author_id', '=', $user->id)->orderBy('created_at', 'DESC')->paginate(25);
     $added_shows = Show::where('author_id', '=', $user->id)->orderBy('created_at', 'DESC')->paginate(25);
     return View::make('user.dashboard', array('user' => $user, 'added_events' => $added_events, 'added_shows' => $added_shows, 'pageTitle' => 'Dashboard'));
 }
示例#2
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     // Fetch all request data.
     $data = Input::only('title', 'extra_url', 'event_id');
     $event_id = Input::get('event_id');
     // Build the validation constraint set.
     $rules = array('title' => array('required', 'min:3'), 'extra_url' => array('required', 'Url'), 'event_id' => array('required', 'integer', 'sometimes'));
     // Create a new validator instance.
     $validator = Validator::make($data, $rules);
     if ($validator->passes()) {
         $extra = new Extra();
         $current_user = Sentry::getUser();
         if ($current_user->hasAccess('admin') || $current_user->hasAccess('verified')) {
             $extra->approved = '1';
         }
         $extra->author_id = Sentry::getUser()->id;
         $extra->title = Input::get('title');
         $extra->extra_url = Input::get('extra_url');
         $extra->save();
         $event = ep\Event::find($event_id);
         $event->eventExtra()->save($extra);
         return Redirect::to('/event/' . $event->slug)->with('global_success', 'Event submitted successfuly!');
     }
     return Redirect::to('/event/' . $event->slug)->withInput()->withErrors($validator)->with('message', 'Validation Errors!');
 }
示例#3
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $users = User::all();
     $events_submitted = ep\Event::where('approved', '=', '0')->get();
     $event_count = ep\Event::all()->count();
     $shows_submitted = Show::where('approved', '=', '0')->get();
     $show_count = Show::all()->count();
     $extras_submitted = Extra::where('approved', '=', '0')->get();
     $extra_count = Extra::all()->count();
     $beta_count = DB::table('beta_newsletters')->count();
     return View::make('admin.admin_panel', array('pageTitle' => 'Admin Panel', 'users' => $users, 'event_count' => $event_count, 'events_submitted' => $events_submitted, 'show_count' => $show_count, 'shows_submitted' => $shows_submitted, 'extra_count' => $extra_count, 'beta_count' => $beta_count, 'extras_submitted' => $extras_submitted));
 }
示例#4
0
    } else {
        return Redirect::guest('login');
    }
});
/*
|--------------------------------------------------------------------------
| Author check
|--------------------------------------------------------------------------
|
|	Checks if currently logged in user is author of a resource. Based on URL segment.
|
*/
Route::filter('authorEvent', function () {
    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')) {
示例#5
0
 public function unfavourite($id)
 {
     $user = Sentry::getUser();
     $event = ep\Event::find($id);
     $fav_check = $event->eventUser()->where('user_id', '=', $user->id)->first();
     if ($fav_check == false) {
         return Redirect::to(URL::to('/'))->with('global_error', 'This event doesn\'t exists in your favourites.');
     } else {
         $event->eventUser()->detach($user);
         return Redirect::to(URL::previous())->with('global_success', 'Event has been removed from favourites.');
     }
 }