public function run()
 {
     if (isset($_SESSION[$this->app->config->get('auth.session')])) {
         $this->app->auth = User::with('roles', 'advisor', 'queues')->where('id_user', $_SESSION[$this->app->config->get('auth.session')])->first();
     }
     $this->app->view()->appendData(['auth' => $this->app->auth, 'baseUrl' => $this->app->config->get('app.url')]);
 }
Beispiel #2
0
        $app->render('admin/admin.edituser.html.twig', ['errors' => $v->errors(), 'request' => $request, 'user' => $user, 'roles' => $roles, 'advisors' => $advisors]);
    }
})->name('admin.resetPassword');
/*
   Route: Admin Delete User(s)
   Name: admin.deleteUser
*/
$app->post('/admin/user/delete', $authorizationCheck(['ADMIN']), function () use($app) {
    $request = $app->request;
    $userIdsStr = $request->post('userIds');
    if (isset($userIdsStr) && $userIdsStr != "") {
        // Convert the comma delimited string of user ids into an array of ints
        $userIds = array_map('intval', explode(",", $userIdsStr));
        // Loop through each user id
        foreach ($userIds as $userId) {
            $user = User::where('id_user', $userId)->first();
            // Delete user role database records in the many-to-many pivot table user_roles
            $user->roles()->detach();
            // Delete the user record
            $user->delete();
        }
        $app->flash('global', "User(s) deleted");
    }
    return $app->response->redirect($app->urlFor('admin.users'));
})->name('admin.deleteUser');
/*
   Route: Admin Course Home
   Name: admin.courses
*/
$app->get('/admin/course', $authorizationCheck(['ADMIN']), function () use($app) {
    /*