/** * Responds to requests to GET / */ public function getIndex() { if (\Auth::check()) { return redirect()->to('/books'); } return view('welcome.index'); }
public function register() { if (\Auth::check()) { return redirect('/dashboard'); } return view('auth.register'); }
public function index(\App\Gameweek $gameweek = null, \App\Month $month = null) { $user = null; $users = \App\User::ranked()->orderBy('rank')->get(); $lastFixture = \App\Fixture::over()->orderBy('kickoff', 'desc')->first(); $activeTabs = ['active', '', '']; if (!$month or !$month->hasStarted()) { $month = $lastFixture->gameweek->month; } else { $activeTabs = ['', 'active', '']; } if (!$gameweek or !$gameweek->hasCompletedFixture()) { $gameweek = $lastFixture->gameweek; } else { $activeTabs = ['', '', 'active']; } if (\Auth::check()) { $user = \Auth::user(); } $months = \App\Month::orderBy('id', 'desc')->get()->filter(function ($month) { return $month->hasStarted(); }); $gameweeks = \App\Gameweek::orderBy('id', 'desc')->get()->filter(function ($gw) { return $gw->hasCompletedFixture(); }); $gameweekUsers = $gameweek->predictors()->orderBy('gameweek_user.rank', 'asc')->get(); $monthUsers = $month->users()->orderBy('month_user.rank', 'asc')->get(); $nameOfPage = 'standings'; return view('pages.standings', compact('gameweeks', 'months', 'users', 'gameweekUsers', 'monthUsers', 'month', 'gameweek', 'user', 'activeTabs', 'nameOfPage')); }
public function store() { //checks if the user is authorised to add school if (\Auth::check()) { $newschoolname = Request::get('schoolname'); // calls the school name from the school view file $newschoolurl = Request::get('schoolURL'); // calls the school url from the school view file school::insert(['school_name' => $newschoolname, 'school_url' => $newschoolurl]); //inserts the new data into a new tuple $message = "School Added: Success"; // indicates success to the user } else { $message = "School Added: Failed"; } // indicates failure to the user $schooltable = school::all(); //calls the schools from the model school. all() selects all, included the new entry //Tells user if logged in or not. necessary for the view if (\Auth::check()) { $name = \Auth::user()->name; } else { $name = "Guest"; } //returns the school view, and passes the schooltable, the message, and user name to the view return view('school', compact('schooltable', 'message', 'name')); }
public function store($department_name, $department_number) { //Checks if user is Authorised if (\Auth::check()) { $newdescription = Request::get('description'); //gets description from courses view $newcoursenumber = Request::get('sectionnumber'); //gets section number from courses view //creates the new tuple course::insert(['department_name' => $department_name, 'dept_num' => $department_number, 'Description' => $newdescription, 'sectionnumber' => $newcoursenumber]); $message = "Add Course: Success"; //tells user that it was a success } else { $message = "Add Course: Failed"; } //tells user if it was a failure // filters results based on variables passed in to function to display desired courses. It will contain new tuple if successful $coursetable = course::where('dept_num', '=', $department_number)->where('department_name', '=', $department_name)->orderBy('sectionnumber', 'asc')->get(); //tells user if logged in or not if (\Auth::check()) { $name = \Auth::user()->name; } else { $name = "Guest"; } //returns the view courses. It passes coursetable, department_name, department_number, message, and name to the view return view('courses', compact('coursetable'), compact('department_name', 'department_number', 'message', 'name')); }
public function store($school_name) { //Checks if user is authorised to add a new tuple if (\Auth::check()) { $newdepartmentname = Request::get('departmentname'); //gets the department name from the department view $newdepartmenturl = Request::get('departmentURL'); //gets the department url from the department view //adds a new tuple to the department table. Note department number is an auto incremented integer. department::insert(['department_name' => $newdepartmentname, 'dept_url' => $newdepartmenturl, 'school_name' => $school_name]); $message = "Department Added: Success!"; // indicates that the tuple was added } else { $message = " Department Added: Failed"; } // indicates that the new tuple was not added //filters department table based on $school_name, which was passed into function. It includes new Tuple if successful $departmenttable = department::where('school_name', '=', $school_name)->get(); //Tells user if logged in or not in view if (\Auth::check()) { $name = \Auth::user()->name; } else { $name = "Guest"; } //returns the view department. It passes the departmenttable, school_name, message, and name to the view return view('department', compact('departmenttable'), compact('school_name', 'message', 'name')); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { if (\Auth::check()) { if (\Auth::user()->role_id == 2) { $is_mainadmin = false; $professors_verified = DB::table('professors')->join('users', 'users.id', '=', 'professors.user_id')->join('institutions', 'institutions.id', '=', 'professors.inst_id')->where('is_verified', true)->where('role_id', 3)->get(); $professors_pending = DB::table('professors')->join('users', 'users.id', '=', 'professors.user_id')->join('institutions', 'institutions.id', '=', 'professors.inst_id')->where('is_verified', false)->where('role_id', 3)->get(); $num_verified = collect($professors_verified)->count(); $num_pending = collect($professors_pending)->count(); switch ($id) { case 'professors-verified': $is_verified = true; return view('inst_admin.professor_inst', compact('is_mainadmin', 'is_verified', 'num_pending', 'num_verified', 'professors_verified')); break; case 'professors-pending': $is_verified = false; return view('inst_admin.professor_inst', compact('is_mainadmin', 'is_verified', 'num_pending', 'num_verified', 'professors_pending')); break; case 'courses': return view('admin_shared.courses', compact('is_mainadmin')); break; case 'settings': $email = \Auth::user()->email; return view('admin_shared.settings', compact('is_mainadmin', 'email', 'num_verified', 'num_pending')); break; default: return abort(404); } } else { return redirect('/'); } } }
public function check() { if (\Auth::check()) { return Response::json(array('result' => true, 'data' => 'Authed')); } return Response::json(array('result' => false, 'data' => 'fail')); }
/** * Display a listing of the resource. * * @return Response */ public function index(Request $request) { $name = $request->input('name'); $artist = $request->input('artist'); $type = 1; $view; if (\Auth::check()) { if (\Auth::User()->roll == "Administrador") { $view = 'songs.index'; } else { if (\Auth::User()->roll == "Cliente") { $view = 'songs.songs_user'; } } if ($name == null && $artist == null) { $songs = Song::getsongs(); return view($view, compact('songs')); } else { if ($name != null && $artist == null) { $songs = \App\Models\Song::search_by_song($name, $type); return view($view, compact('songs')); } else { if ($name == null && $artist != null) { $songs = \App\Models\Song::search_by_singer($artist); return view($view, compact('songs')); } else { $songs = \App\Models\Song::search_by_singer_song($name, $artist); return view($view, compact('songs')); } } } } else { return view('auth.login'); } }
/** * Show the application dashboard. * * @return \Illuminate\Http\Response */ public function index() { if (\Auth::check()) { return view('home'); } return redirect()->action('HomeController@index'); }
public function logout() { if (\Auth::check()) { \Auth::logout(); } return \Redirect::back(); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($id) { if (\Auth::check()) { if (\Auth::user()->role_id == 3) { switch ($id) { case 'edit': $professor = DB::table('professors')->join('users', 'professors.user_id', '=', 'users.id')->where('users.id', '=', \Auth::user()->id)->first(); return view('professor.edit_profile', compact('professor')); break; case 'settings': $is_mainadmin = false; $is_professor = true; $professor = DB::table('professors')->join('users', 'professors.user_id', '=', 'users.id')->where('users.id', '=', \Auth::user()->id)->first(); $email = \Auth::user()->email; return view('shared.settings', compact('is_mainadmin', 'is_professor', 'professor', 'email')); break; case 'assigned-courses': $prof_id = DB::table('professors')->where('user_id', \Auth::user()->id)->first()->prof_id; $is_mainadmin = false; $is_professor = true; $courses = DB::table('courses')->where('prof_id', $prof_id)->get(); $professor = DB::table('professors')->join('users', 'professors.user_id', '=', 'users.id')->where('users.id', '=', \Auth::user()->id)->first(); return view('shared.courses', compact('courses', 'is_mainadmin', 'is_professor', 'professor')); break; default: return abort(404); } } else { return redirect('/'); } } else { return redirect('/'); } }
public function index(Guard $auth, PedidoProduto $pedidoProduto) { if (\Auth::check()) { $idPagseguro = substr(md5(uniqid()), 0, 15); $dados = $auth->user(); $produtosNoCarrinho = Cart::content(); foreach ($produtosNoCarrinho as $produtoNoCarrinho) { $attributes = ['tb_pedidos_produto_cliente' => $dados->id, 'tb_pedidos_produto_id_pagseguro' => $idPagseguro, 'tb_pedidos_produto_quantidade' => $produtoNoCarrinho->qty, 'tb_pedidos_produto_subtotal' => $produtoNoCarrinho->subtotal, 'tb_pedidos_produto_id' => $produtoNoCarrinho->id, 'tb_pedidos_produto_data' => date('Y-m-d H:i:s')]; $pedidoProduto->create($attributes); } $pagseguro = new Pagseguro($dados); $dadosPedidoPagseguro = ['id' => $idPagseguro, 'produto' => 'Vendas da Loja', 'preco' => Cart::total()]; $pagseguro->setNome($dados->name); $pagseguro->setSobrenome(''); $pagseguro->setEmail($dados->email); $pagseguro->setDdd(''); $pagseguro->setTelefone(''); $pagseguro->setIdReference($idPagseguro); $pagseguro->setItemAdd($dadosPedidoPagseguro); try { $url = $pagseguro->enviarPagseguro(); echo $url; } catch (\Exception $e) { echo $e->getMessage(); } } else { return 'logado'; } }
public function getLogin() { if (\Auth::check()) { \Auth::user()->email; } return view('pages.users.login'); }
public function getSpeakers(string $id_slug = null) { $single_theme = isset($id_slug); if (!$id_slug) { /** @var Theme[] $themes */ $theme = null; if (\Auth::check()) { $themes = \Auth::user()->all_themes; } else { $themes = Theme::mostFrequent(); } } else { $id = unslug($id_slug)[0]; $theme = Theme::find($id); $themes = [$theme]; //FIXME: find a way to create a list of "related" themes } $speakers = []; foreach ($themes as $t) { //take care to not override $theme foreach ($t->sessions as $session) { /** @var \App\Models\Session $session */ $speakers += $session->speakers->all(); } } $themed_speakers = (bool) sizeof($speakers); if (!$speakers) { $speakers = User::findSpeakers(); } return view('user.speakers', compact('theme', 'themes', 'speakers', 'themed_speakers', 'single_theme')); }
/** * Logout * * @return Response */ public function logout() { if (\Auth::check()) { \Auth::logout(); } return \Redirect::route('home.index'); }
public function store($TID, $CID) { //checks if user is authorised if (\Auth::check()) { $newfiletype = Request::get('filetype'); //gets file type from contentfolder view //inserts new tuple to contentfoldertable contentfolder::insert(['TuID' => $TID, 'CIDe' => $CID, 'filename' => $newfiletype]); $message = "Add Content Folder: Sucess!"; //tells user addition was successful } else { $message = "Add Content: Failure"; // tells user that addition was a failure } //tells user if logged in or not if (\Auth::check()) { $name = \Auth::user()->name; } else { $name = "Guest"; } //filters table based on TID and CID. kantfolder is a philosophical variable, if you will it. $kantfolder = contentfolder::where('TuID', '=', $TID)->where('CIDe', '=', $CID)->get(); //returns the contentfolder view. It passes kantfolder, TID, CID, message, and name to contentfolder view return view('contentfolder', compact('kantfolder'), compact('TID', 'CID', 'message', 'name')); }
public function show($name) { if (\Auth::check() && \Auth::user()->permission->name == 'admin') { if (is_numeric($name)) { $dl = Downloads::where('id', '=', $name)->where('trash', '=', '0')->first(); if (is_null($dl)) { return \Redirect::to('404'); } return \View::make('downloads.show')->with('entry', $dl); } else { $dl = Downloads::where('name', '=', $name)->where('trash', '=', '0')->first(); if (is_null($dl)) { return \Redirect::to('404'); } return \View::make('downloads.show')->with('entry', $dl); } } else { if (is_numeric($name)) { $dl = Downloads::where('id', '=', $name)->where('trash', '=', '0')->where('state', '=', '1')->first(); if (is_null($dl)) { return \Redirect::to('404'); } return \View::make('downloads.show')->with('entry', $dl); } else { $dl = Downloads::where('name', '=', $name)->where('trash', '=', '0')->where('state', '=', '1')->first(); if (is_null($dl)) { return \Redirect::to('404'); } return \View::make('downloads.show')->with('entry', $dl); } } }
public function __construct() { $this->middleware('auth', ['except' => 'create']); if (\Auth::check()) { $this->middleware('filter'); } }
public function open() { if (!\Auth::check()) { return view('start'); } return \Redirect::action('HomeController@dashboard'); }
public function create() { if (Auth::check()) { return Redirect::to("/admin"); } return View::make("sessions.create"); }
public function showLogin() { if (\Auth::check()) { return \Redirect::to('admin'); } else { return view('auth.login'); } }
public function __construct() { if (\Auth::check()) { $this->userName = \Auth::user()->name; } else { $this->userName = self::GUEST_USER; } }
/** * Responds to requests to GET / */ public function getIndex() { # Logged in users should not see the welcome page, send them to the books index instead. if (\Auth::check()) { return redirect()->to('/accounts'); } return view('welcome'); }
public function index() { if (\Auth::check()) { return view('admin.index'); } else { return \Redirect::to('auth/login'); } }
public function checkLogged() { if (\Auth::check()) { return redirect()->route('home'); } else { return redirect()->route('home'); } }
/** * * * @return view */ public function register() { if (\Auth::check()) { return redirect('dashboard'); } else { return view('user.register'); } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function getIndex() { if (\Auth::check()) { return redirect('/store'); } return view('welcome.index'); }
public function __construct() { if (\Auth::check()) { $this->authUser = \Auth::user(); view()->share('authUser', $this->authUser); } }
public function getRegister() { if (Auth::check()) { return Redirect::to("/"); } return View::make('auth.register'); }