Ejemplo n.º 1
0
 public function desactivate($id)
 {
     $response = Response::findOrFail($id);
     $response->active = 0;
     $response->save();
     return Redirect::route('admin.questions.show', ['id' => $response->question->id])->with(['message' => 'Response desactivated successfully.']);
 }
Ejemplo n.º 2
0
 public function dashboard()
 {
     $count_users = User::all()->count();
     $count_questions = Question::all()->count();
     $count_responses = Response::all()->count();
     $count_unanswered_questions = Question::where('active', '=', '1')->whereNotIn('id', Response::distinct()->get(['question_id'])->toArray())->count();
     return View::make('dashboard', ['count_users' => $count_users, 'count_questions' => $count_questions, 'count_responses' => $count_responses, 'count_unanswered_questions' => $count_unanswered_questions]);
 }
Ejemplo n.º 3
0
//auth must be admin
//Profile
Route::get('/profile', ['before' => 'auth', 'uses' => 'UserController@profile', 'as' => 'profile']);
Route::post('/profile/update', ['before' => 'auth', 'uses' => 'UserController@profileUpdate', 'as' => 'profile.update']);
//Responses
Route::post('/responses', ['uses' => 'ResponseController@store', 'as' => 'responses.store', 'before' => 'auth']);
Route::get('/admin/responses/activate/{id}', ['uses' => 'ResponseController@activate', 'as' => 'responses.activate', 'before' => 'auth.admin']);
//auth must be admin
Route::get('/admin/responses/desactivate/{id}', ['uses' => 'ResponseController@desactivate', 'as' => 'responses.desactivate', 'before' => 'auth.admin']);
//auth must be admin
Route::get('/admin/responses/delete/{id}', ['uses' => 'ResponseController@delete', 'as' => 'responses.delete', 'before' => 'auth.admin']);
//auth must be admin
//Tags
Route::get('/tags', ['uses' => 'TagController@json', 'as' => 'tags']);
//Notifications
Route::get('/notifications', ['uses' => 'NotificationController@index', 'as' => 'notifications', 'before' => 'auth']);
Route::post('/notifications/store', ['uses' => 'NotificationController@store', 'as' => 'notifications.store', 'before' => 'auth']);
Route::get('/notifications/read/{id}', ['uses' => 'NotificationController@markAsRead', 'as' => 'notifications.read', 'before' => 'auth'])->where(['id' => '\\d']);
//Shared data
$shared_views = ['user.questions', 'user.question', 'user.create_question', 'admin.questions', 'admin.questions.show', 'admin.users', 'admin.create_user', 'admin.edit_user', 'user.profile', 'admin.question', 'user.notifications', 'dashboard'];
View::composer($shared_views, function ($view) {
    $users = User::where('active', '=', 0)->get();
    $count_users = count($users);
    $questions = \Neoos\Foto\Models\Question::where('active', '=', 0)->get();
    $count_questions = count($questions);
    $responses = \Neoos\Foto\Models\Response::where('active', '=', 0)->get();
    $count_responses = count($responses);
    $notifications = Auth::user()->notifications()->where('new', '=', 1)->get();
    $count_notifications = count($notifications);
    $view->with(['inactive_users' => $users, 'count_inactive_users' => $count_users, 'inactive_questions' => $questions, 'count_inactive_questions' => $count_questions, 'inactive_responses' => $responses, 'count_inactive_responses' => $count_responses, 'inactive_notifications' => $notifications, 'count_inactive_notifications' => $count_notifications]);
});