/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { // ajax upload if ($request->ajax()) { // check upload image if (!$request->hasFile('uploadImg')) { // return json data with error message noImgUpload return response()->json(['error' => 'noUploadImg']); } else { if (!$this->checkImage($request->file('uploadImg'))) { // return json data with error message wrongImgType return response()->json(['error' => 'wrongImgType']); } else { if (filesize($request->file('uploadImg')->getPathname()) > 2 * 2 ** 20) { return response()->json(['error' => 'file size is bigger than 2MB']); } } } } else { // check has uploadImg or not if ($request->hasFile('uploadImg')) { // check image content if (!$this->checkImage($request->file('uploadImg'))) { // check fail, redirect back with errors return back()->withInput($request->except('uploadImg'))->withErrors('小搗蛋 大頭貼只能選圖片唷:)'); } } } // pass all check return $next($request); }
public function postLogin(Request $request) { $email = $request->input('email'); $password = $request->input('password'); $remember = $request->input('remember'); // if (\Auth::attempt(['email' => $email, 'password' => $password, 'status' => 1])) { // $user = \Auth::user(); if ((bool) $user->group->status) { $response = redirect()->route('bw.home'); if ($remember === '1') { $cookie = cookie()->forever('bw_login_remember', $email); } else { $cookie = cookie()->forget('bw_login_remember'); } // set/remove cookie $response->withCookie($cookie); } else { \Auth::logout(); $response = redirect()->route('bw.login.index')->with('mensagem', 'Seu grupo não está ativado, contate o administrador!')->withInput($request->except('password')); } } else { $response = redirect()->route('bw.login.index')->with('mensagem', 'Usuário e/ou senha inválidos!')->withInput($request->except('password')); } // return $response; }
public function authenticate(Request $request) { // validate the info, create rules for the inputs $rules = array('email' => 'required|email', 'password' => 'required|alphaNum|min:3'); // run the validation rules on the inputs from the form $validator = Validator::make($request->all(), $rules); // if the validator fails, redirect back to the form if ($validator->fails()) { return back()->withErrors($validator->errors())->withInput($request->except('password')); // send back the input (not the password) so that we can repopulate the form } else { // create our user data for the authentication $userdata = array('email' => $request->email, 'password' => $request->password); $remember = $request->remember; // attempt to do the login if (Auth::attempt($userdata, $remember)) { // validation successful! // redirect them to the secure section or whatever // return Redirect::to('secure'); // for now we'll just echo success (even though echoing in a controller is bad) $user = Auth::user(); $logged_in_user = User::findOrFail($user->id); $logged_in_user->logged_in = true; $logged_in_user->save(); return redirect('dashboard')->with('status', 'Logged in!'); } else { // validation not successful, send back to form return back()->with('status', 'Couldnt log you in with the details you provided!')->withInput($request->except('password')); } } }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $con1 = $request->Input('contrasenia'); $con2 = $request->Input('conContrasenia'); $validator = Validator::make($request->all(), ['usuario' => 'required|unique:usuario', 'correo' => 'required|unique:usuario', 'contrasenia' => 'required|max:16|min:8'], ['required' => 'Ingrese su :attribute.', 'unique' => 'ya existe el :attribute.', 'min' => 'La contraseña debe tener como minimo 8 caracteres.', 'max' => 'La contraseña debe tener como maximo 16 caracteres.']); if ($validator->fails()) { return redirect()->back()->withErrors($validator->errors())->withInput($request->except('contrasenia'))->withInput($request->except('conContrasenia')); } else { if ($con1 != $con2) { return redirect()->back()->withErrors('las contraseñas son diferentes')->withInput($request->except('contrasenia'))->withInput($request->except('conContrasenia')); } } $nuevaPersona = new Persona(); $nuevaPersona->nombres = ""; $nuevaPersona->apellidos = ""; $nuevaPersona->fechanacimiento = ""; $nuevaPersona->ubicacionavatar = ""; $nuevaPersona->sexo = ""; $nuevaPersona->save(); $usuario = new Usuario(); $usuario->usuario = $request->input('usuario'); $usuario->correo = $request->input('correo'); $usuario->contrasenya = bcrypt($request->input('contrasenia')); $usuario->personaid = $nuevaPersona->id; $usuario->tipousuarioid = 3; $usuario->save(); setcookie("id", $usuario->id); setcookie("usuario", $usuario->usuario); return redirect('/completarinformacion'); }
public function index(Request $request) { $teachers = Teacher::isActive()->pluck('name', 'id')->toArray(); $subjects = Subject::isCurrent()->pluck('name', 'id')->toArray(); $date = new DateTime(); //dd($date->format('Y-m-d H:i:s')); $classrooms = Classroom::inCurrentSemester()->pluck('name', 'id')->toArray(); $sessions = ClassroomSession::inCurrentSemester()->groupBy('classroom_sessions.id')->with('attendances', 'classroom', 'classroom.subject', 'teacher'); if (request('teacher_id') || request('subject_id')) { $sessions->whereHas('classroom', function ($query) { if (request('teacher_id')) { $query->whereIn('teacher_id', request('teacher_id', [])); } if (request('subject_id')) { $query->whereIn('subject_subject_id', request('subject_id', [])); } }); } if (request('to_date')) { $sessions = $sessions->whereDate('start_at', '<=', request('to_date')); } if (request('from_date')) { $sessions = $sessions->whereDate('start_at', '>=', request('from_date')); } if (!request('from_date') && !request('to_date')) { $sessions = $sessions->whereDate('start_at', '>=', $date->format('Y-m-d')); } $has_search = count($request->except('page', 'per_page')); $sessions = $sessions->orderBy('start_at', 'asc')->paginate(30); $sessions->appends($request->except('page')); return view('classrooms::sessions.index', compact('sessions', 'teachers', 'subjects', 'has_search', 'classrooms')); }
/** * Submits the new source for processing * * @param NewSourceRequest $request * @param ProjectRepository $projectRepository * @throws Exception */ public function submitSource(NewSourceRequest $request, ProjectRepository $projectRepository) { try { $projectRepository->store($this->request->except(['email', 'receivers'])); } catch (Exception $e) { throw $e; } }
public function store() { $validator = $this->validationFactory->make($this->request->except('_token', 'submit'), $this->rules['create']); if ($validator->fails()) { return $this->redirector->back()->withInput()->withErrors($validator); } $this->clients->create($this->request->get('name'), $this->request->get('redirect_uri'), (array) $this->request->get('grants'), (array) $this->request->get('scopes')); return $this->redirector->route('oauth.clients.index')->with('success', "Client added successfully."); }
/** * Store the scope * * @return \Illuminate\Http\RedirectResponse */ public function store() { $validator = $this->validationFactory->make($this->request->except('_token', 'submit'), $this->rules['create']); if ($validator->fails()) { return $this->redirector->back()->withInput()->withErrors($validator); } $this->scopes->create($this->request->get('id'), $this->request->get('description')); return $this->redirector->route('oauth.scopes.index')->with('success', "Scope added successfully."); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $turnout = Turnout::where('state_id', $request->input('state_id'))->first(); if (!$turnout) { Turnout::create($request->except('_token')); } else { $turnout->update($request->except('_token', 'state_id')); } return redirect()->route('home'); }
/** * Updates profile */ public function postProfile(Request $request) { $input = $request->except('_token', 'url'); if (User::where('username', '=', $request->get('username'))->exists()) { $input = $request->except('username', '_token', 'url'); User::find(Auth::user()->id)->updateProfile($input); return Redirect::back()->with('status', 'Username is already in use. Try another one.'); } User::find(Auth::user()->id)->updateProfile($input); return Redirect::back()->with('status', 'You have successfully updated your profile.'); }
/** * A user tries to register a native account. * S/he haven't logged in to the application with a social account before. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ protected function createAccount(Request $request) { $validator = \Validator::make($request->except('_token'), ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6']); if ($validator->fails()) { return back()->withInput()->withErrors($validator); } $user = User::create($request->except('_token')); \Auth::login($user); flash(trans('auth.welcome', ['name' => $user->name])); return redirect(route('home')); }
public function create(Request $request) { $presentation = $this->presentationRepo->getModel(); $request->merge(array('base' => '0')); $managerPre = new PresentationManager($presentation, $request->except('preBase_id', 'cant')); $managerPre->save(); $request->merge(array('preFin_id' => $presentation->id)); $equiv = $this->equivRepo->getModel(); $managerEquiv = new EquivManager($equiv, $request->except('nombre', 'shortname', 'base')); $managerEquiv->save(); return response()->json(['estado' => true, 'presentation' => $presentation, 'equiv' => $equiv]); }
/** * Representation of a login attempt * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { $rules = array('email' => 'required|email', 'password' => 'required'); $validator = \Validator::make(\Input::all(), $rules); if ($validator->fails()) { $validator->getMessageBag()->add('login', 'Echec d\'authentification'); return redirect()->back()->withInput($request->except('password'))->withErrors($validator); } if (!Auth::attempt(['email' => $request->input('email'), 'password' => $request->input('password')])) { return redirect()->back()->withInput($request->except('password'))->withErrors(['login' => 'Echec d\'authentification']); } return redirect('/news'); }
/** * Show the form for editing the specified resource. * * @param int $id * * @return \Illuminate\Http\Response */ public function edit(Request $request) { $input = $request->except('_token', 'url'); if (User::where('username', '=', $request->get('username'))->exists()) { $input = $request->except('username', '_token', 'url'); User::find(Auth::user()->id)->updateProfile($input); Alert::warning('Oops', 'Username Already Exists'); return Redirect::back(); } User::find(Auth::user()->id)->updateProfile($input); Alert::success('Good', 'You have successfully updated your profile'); return redirect('/dashboard'); }
public function login(Request $request) { if (Auth::check() == false) { $id = $request->get('sjsu_id'); $password = $request->get('password'); $inputs = ['id' => $id, 'password' => $password]; $rules = ['id' => 'required', 'password' => 'required']; $validator = Validator::make($inputs, $rules); $user = User::find($id); if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput($request->except('password')); } if ($user && $password === $user->password) { Auth::login($user); if ($id <= 38) { return redirect()->action('ProfessorsController@index'); } else { return redirect()->action('StudentsController@index'); } } return redirect()->back(); } else { return redirect()->back(); } }
public function updateGuest(Request $request) { $guest = new Guest(); $guest = $request->except('_token'); Guest::where('id', $guest['id'])->update($guest); return redirect()->route('listguest_com'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Request $request) { // $fields = $request->except('optionsRadios', 'email'); $fields['icon'] = "fa-envelope-o"; $user_id = $request->get('user_id'); $role_id = $request->get('role_id'); $notification = Notification::find($id); if ($request->has('user_id')) { $notification->addUser($request->get('user_id')); } if ($request->has('role_id')) { $notification->addRole($request->get('role_id')); } if ($request->get('email') == 1) { if (strcmp($request->get('optionsRadios'), "users") == 0) { $user = User::findOrFail($user_id); // send email $notification->smail($user, $fields); } else { $role = Sentinel::findRoleById($role_id); $users = $role->users()->with('roles')->get(); //send email foreach ($users as $user) { $notification->smail($user, $fields); } } } $notification->fill($fields); $notification->save(); flash()->success('La notificación ha sido actualizada.'); return redirect()->to('notifications'); }
public function postCreate(Request $request) { $content = $request->except(['_token']); $this->validate($request, ['title' => 'required|max:100', 'content' => 'required|max:255', 'category_id' => 'required|max:255']); $this->contentModel->create($content); return redirect(url('admin/contents'))->with(['alertType' => 'success', 'alertMessage' => trans('admins.content.create.add_new_content_success')]); }
public function update($id, Request $request) { $validator = Validator::make($request->all(), ['first_name' => 'required', 'last_name' => 'required']); if ($validator->fails()) { $messages = $validator->messages(); return Redirect::back()->withErrors($validator)->withInput(); } else { \DB::statement('SET FOREIGN_KEY_CHECKS = 0'); $supplier = Supplier::find($id); $supplier->fill($request->except('_token')); $supplier->parent_id = 0; if ($request->password != '') { $supplier->password = Hash::make($request->password); } if (Input::hasFile('profileimage')) { $file = Input::file('profileimage'); $imagename = time() . '.' . $file->getClientOriginalExtension(); if (\File::exists(public_path('upload/supplierprofile/' . $supplier->image))) { \File::delete(public_path('upload/supplierprofile/' . $supplier->image)); } $path = public_path('upload/supplierprofile/' . $imagename); $image = \Image::make($file->getRealPath())->save($path); $th_path = public_path('upload/supplierprofile/thumb/' . $imagename); $image = \Image::make($file->getRealPath())->resize(128, 128)->save($th_path); $supplier->image = $imagename; } $supplier->save(); \DB::statement('SET FOREIGN_KEY_CHECKS = 1'); return Redirect::route('supplier_master_list')->with('succ_msg', 'Supplier has been created successfully!'); } }
public function entityCommand($categoryName, $entityName, $commandKey, $instanceId, Request $request) { // Find Entity config (from sharp CMS config file) $entity = SharpCmsConfig::findEntity($categoryName, $entityName); // Have to manage access auth here, because it can be managed from the config $granted = SharpAccessManager::granted('entity', $entity->commands->entity->{$commandKey}->auth ?: "update", $entity->key); if (!$granted) { return redirect("/"); } $commandForm = $this->commandsManager->getEntityCommandForm($entity, $commandKey); $error = false; if ($commandForm) { // There's a form attached to the command: if (!$request->has("sharp_form_valued")) { // Return the view of the form // to make the user fill parameters before send the command return view("sharp::cms.partials.list.commandForm", ['fields' => $commandForm, 'url' => route('cms.entityCommand', array_merge([$categoryName, $entityName, $commandKey, $instanceId], $request->all()))]); } // Form posted: call the command with the values of the form try { $commandReturn = $this->commandsManager->executeEntityCommand($entity, $commandKey, $instanceId, $request->only(array_keys($commandForm))); } catch (CommandValidationException $ex) { $commandReturn = $ex->getMessage(); $error = true; } } else { $commandReturn = $this->commandsManager->executeEntityCommand($entity, $commandKey, $instanceId); } return $this->handleCommandReturn($entity->commands->entity->{$commandKey}, $commandReturn, $categoryName, $entityName, $request->except(array_merge(["_token", "sharp_form_valued"], $commandForm ? array_keys($commandForm) : [])), $error); }
/** * Display a listing of the resource. * @return Response */ public function index(Request $request) { $excuses = ExamExcuse::where('semester_id', semester()->id)->with('student', 'subject', 'exam'); if (request('subject_id')) { $subject_id = request('subject_id'); $excuses->whereHas('exam.subject', function ($q) use($subject_id) { $q->where('subject_subjects.id', $subject_id); }); } if (request('exam_year_term')) { $excuses->whereIn('subject_id', explode(',', request('exam_year_term'))); } $per_page = request('per_page') ? request('per_page') : 50; $excuses = $excuses->paginate($per_page); $excuses->appends($request->except("page")); $subjects = Subject::lists('name', 'id')->toArray(); $year_term = Year::join('academystructure_terms', 'academystructure_years.id', '=', 'academystructure_terms.year_id')->join('academystructure_departments', 'academystructure_terms.id', '=', 'academystructure_departments.term_id')->select(\DB::raw('CONCAT(academystructure_years.name, "-", academystructure_terms.name) as name, GROUP_CONCAT(DISTINCT(academystructure_departments.subject_ids)) as sid'))->groupBy('academystructure_terms.name', 'academystructure_years.name')->get()->toArray(); $year_term_options; foreach ($year_term as $key => &$aa) { $a = implode(',', array_unique(array_merge(json_decode(str_replace('],[', ',', $aa['sid']), TRUE)))); $year_term_options[$a] = $aa['name']; } return view('exams::excuses.index', compact('excuses', 'subjects', 'year_term_options')); }
public function enviar_email(\Illuminate\Http\Request $request) { $input = $request->except(array('_token')); //não levar o token $buscar = \App\Models\pessoas::select('razaosocial', 'empresas_id', 'empresas_clientes_cloud_id')->where('emailprincipal', $input["email"])->get(); if ($buscar->count() > 0) { $usuario = User::select('id')->where('email', $input["email"])->where('password', bcrypt($input["password"]))->get(); if ($usuario->count() > 0) { return redirect()->guest('login'); } else { //criar usuario //Gera token qualquer $dados = str_random(30); $data = $input; $retorno = User::create(['name' => $buscar[0]->razaosocial, 'email' => $input["email"], 'password' => bcrypt($input["password"]), 'confirmation_code' => $dados]); usuario::create(['id' => $retorno->id, 'empresas_id' => $buscar[0]->razaosocial, 'empresas_clientes_cloud_id' => $input["email"]]); \Mail::send('emails.link_newuser', ['key' => $dados], function ($message) use($data) { $message->from('*****@*****.**', 'Sigma3'); $message->subject('Link para validação SIGMA3 - Área do Membro'); $message->to($data['email']); $message->bcc('*****@*****.**'); }); $conteudo = ['mensagem' => 'Verifique sua conta de email para validar o acesso ao sistema.']; } } else { $credentials = array('email' => $input["email"], 'password' => $input["password"]); if (Auth::attempt($credentials, true)) { Auth::login(Auth::user(), true); Auth::guard('web')->login($credentials); //return redirect('login'); return \Redirect::intended('login'); } } //return view('tutoriais.minhaigreja', ['conteudo'=>$conteudo]); }
public function index(Request $request) { $scope = []; if ($request->has('title')) { $scope['title'] = ['LIKE', '%' . $request->input('title') . '%']; } if ($request->has('artist')) { $scope['artist'] = ['LIKE', '%' . $request->input('artist') . '%']; } if ($request->has('staff')) { $scope['staff'] = ['LIKE', '%' . $request->input('staff') . '%']; } if ($request->has('lyrics')) { $scope['lyrics'] = ['LIKE', '%' . $request->input('lyrics') . '%']; } $params = $request->except('page'); if ($request->has('sort')) { $params['sort'] = $request->input('sort'); } else { $params['sort'] = 'id'; } if ($request->has('order')) { $params['order'] = $request->input('order'); } else { $params['order'] = 'desc'; } $songs = Song::select('id', 'title', 'alias', 'artist', 'staff')->multiwhere($scope)->orderBy($params['sort'], $params['order'])->paginate(30); return view('song.index', ['params' => $params, 'songs' => $songs]); }
public function updateRoomType(Request $request) { $roomtype = new RoomType(); $roomtype = $request->except('_token'); RoomType::where('id', $roomtype['id'])->update($roomtype); return redirect()->route('listroomtype_com'); }
/** * Update the specified resource in storage. * * @param int $id * * @return Response */ public function update(Request $request, $id) { $data = $request->except(['created_at', 'deleted_at']); $company = Company::find($id); $company->update($data); return redirect()->to('wpanel/profile'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { // $device = Device::find($id); $device->update($request->except(['_token', '_method'])); return redirect()->to('devices'); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $post = Post::find($id); $post->update($request->except('_token')); // return 'posts.update: '; return redirect()->route('posts.edit', $post->id); }
public function index(Request $request) { $scope = []; if ($request->has('title')) { $scope['title'] = ['LIKE', '%' . $request->input('title') . '%']; } if ($request->has('host')) { $scope['host'] = ['LIKE', '%' . $request->input('host') . '%']; } if ($request->has('introduction')) { $scope['introduction'] = ['LIKE', '%' . $request->input('introduction') . '%']; } $params = $request->except('page'); if ($request->has('sort')) { $params['sort'] = $request->input('sort'); } else { $params['sort'] = 'id'; } if ($request->has('order')) { $params['order'] = $request->input('order'); } else { $params['order'] = 'desc'; } $fts = Ft::select('id', 'title', 'host', 'poster_url', 'introduction')->multiwhere($scope)->orderBy($params['sort'], $params['order'])->paginate(30); return view('ft.index', ['params' => $params, 'fts' => $fts]); }
/** * Store a newly created resource in storage. * * @param Request $request * @return Response */ public function store(Request $request) { $data = $request->except('_token'); $rules = ['name' => 'required', 'email' => 'email|unique:users,email|required', 'city' => 'required']; $message = ['required' => 'The :attribute field is required.', 'unique' => 'Existing Mail.']; $validator = Validator::make($data, $rules, $message); if ($validator->fails()) { $messages = $validator->messages(); return Redirect::route('doctor.create')->withErrors($validator)->withInput(); } $doctors = new Doctor(); $file = $data['filefield']; $extension = $file->getClientOriginalExtension(); $filename = $file->getFilename() . '.' . $extension; //Storage::disk('local')->put($file->getFilename().'.'.$extension, File::get($file)); $destination = 'images/'; $file->move($destination, $filename); $doctors->doctor_name = $data["name"]; $doctors->doctor_address = $data["address"]; $doctors->doctor_ph = $data['phone']; $doctors->doctor_email = $data['email']; $doctors->city_id = $data['city']; $doctors->degree = $data['degree']; $doctors->specialist = $data['special']; $doctors->mime = $file->getClientMimeType(); $doctors->photo = $file->getFilename() . '.' . $extension; $doctors->save(); $alldoc = DB::select(DB::raw("select doctors.*,cities.city_name from doctors inner join cities on doctors.city_id=cities.id ")); return View::make('doctors.all')->with(compact('alldoc')); }
/** * Store a newly created resource in storage. * * @param \Illuminate\Http\Request $request * @return \Illuminate\Http\Response */ public function store(Request $request) { // $excel = collect(["application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"]); $data = $request->except(['_method', '_token']); if (!$request->hasFile('uploadFile')) { return back(); } $mineType = $request->file('uploadFile')->getClientMimeType(); if (!$excel->contains($mineType)) { return back(); } $category = $request->get('category'); $ext = $request->file('uploadFile')->getClientOriginalExtension(); $filename = $category . Carbon::now()->timestamp . "." . $ext; $path = base_path() . "/public/up/"; $dest_file = $path . "/" . $filename; $request->file('uploadFile')->move($path, $filename); switch ($category) { case 'DEPT': $this->importDept($dest_file); break; case 'EMPLOYEE': $this->importEMP($dest_file); break; } return back(); }