public function profile() { $user = User::getData(); if (!empty($user)) { // setting a new properity for the user permission $permission = PermissionModel::first('user_id = ?', [$user->id]); $user->permission = $permission->permission; // if the user is admin then will fetch the not replied complains $requests = null; if ($permission->permission == 'admin') { $requests = ComplainModel::with(['status' => 'bending']); if (count($requests)) { foreach ($requests as $request) { // fetching the data for the patient who made the complain $request->patient = UserModel::id($request->user_id); } } $requests_count = count($requests); return twig('profile-admin.html', ['user' => $user, 'requests' => $requests, 'requests_count' => $requests_count]); } $msgs = $complains = null; if ($permission->permission == 'normal') { // fetching the current user messages $msgs = MessageModel::with(['user_id' => $user->id]); // fetching the current user complains $complains = ComplainModel::with(['user_id' => $user->id]); $msgs_count = count(MessageModel::with(['user_id' => $user->id, 'viewed' => 0])); return twig('profile-user.html', ['user' => $user, 'complains' => $complains, 'msgs' => $msgs, 'msgs_count' => $msgs_count]); } } else { Session::flash("msg", '<li><span class="msg-warning">Warning: </span> Humm!... you want to cheat, access denied</li>'); goBack(); } }
public function index() { return twig('index.html'); }
public static function error($code) { if (is_numeric($code)) { $txt = ''; switch ($code) { case 404: // Page was not found: header('HTTP/1.1 404 Not Found'); $txt = twig(Config::app('url.error.404')); break; case 403: // Access forbidden: header('HTTP/1.1 403 Forbidden'); $txt = twig(Config::app('url.error.403')); break; case 500: // Server error header('HTTP/1.1 500 Internal Server Error'); $txt = twig(Config::app('url.error.500')); break; case 301: // The page moved permanently should be used for // all redrictions, because search engines know // what's going on and can easily update their urls. header('HTTP/1.1 301 Page Moved Permanently'); $txt = twig(Config::app('url.error.301')); break; case 401: header('HTTP/1.1 401 Unauthorized: Access is denied due to invalid credentials'); $txt = twig(Config::app('url.error.401')); break; } die($txt); } }
public function index() { return twig('login.html'); }