/** * Checks if the product is new, and sets the created and modified times appropriately, * prior to saving. * @see testProjectModel::beforeSave() */ public function beforeSave() { if ($this->isNew) { $this->created = date("Y-m-d H:i:s"); $this->modified = $this->created; $this->user = Auth::User()->id; } else { $this->modified = date("Y-m-d H:i:s"); } $tags = isset($this->attributes['tags']) ? $this->attributes['tags'] : array(); foreach ($tags as $i => $tag) { if (!is_numeric($tag)) { $tagModel = new tags(array('name' => $tag)); $tagModel->save(); $tags[$i] = $tagModel->id; } else { $tags[$i] = intval($tag); } } $this->tagIds = $tags; unset($this->attributes['tags']); if (!is_numeric($this->vendor)) { $vendor = new vendors(array('name' => $this->vendor)); $vendor->save(); $this->vendor = $vendor->id; } $this->cleanDates(array('purchaseDate', 'saleDate', 'soldDate')); return true; }
public function postSignIn() { $email = Input::get('email'); $password = Input::get('password'); $remember = Input::get('remember_me'); $validation = new SeatUserValidator(); if ($validation->passes()) { // Check if we got a username or email for auth $identifier = filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL) ? 'email' : 'username'; // Attempt authentication using a email address if (Auth::attempt(array($identifier => $email, 'password' => $password), $remember ? true : false)) { // If authentication passed, check out if the // account is activated. If it is not, we // just logout again. if (Auth::User()->activated) { return Redirect::back()->withInput(); } else { // Inactive account means we will not keep this session // logged in. Auth::logout(); // Return the session back with the error. We are ok with // revealing that the account is not active as the // credentials were correct. return Redirect::back()->withInput()->withErrors('This account is not active. Please ensure that you clicked the activation link in the registration email. '); } } else { return Redirect::back()->withErrors('Authentication failure'); } } return Redirect::back()->withErrors($validation->errors); }
/** * Función responsable de autenticar a un usuario en la aplicación */ public function doLogin() { $response = null; try { // Se validan las credenciales. $validator = $this->validateCredentials(); if ($validator->passes()) { $remember = false; // por defecto no recuerda el usuario autenticado. $credentials = $this->getLoginCredentials(); // se verifica si el usuario fue autenticado if (Auth::attempt($credentials, $remember)) { // se retorna la información del usuario cuando este es autenticado. $response = $this->respondWithItem(Auth::User(), new UserTransformer()); } else { $response = $this->respondWithError(self::MESSAGE_COULD_NOT_AUTHENTICATE, self::CODE_COULD_NOT_AUTHENTICATE); } } else { $response = $this->respondWithError($validator->messages(), self::CODE_WRONG_ARGUMENTS); } } catch (Exception $e) { $response = $this->errorInternalError($e->getMessage()); } return $response; }
public function logoutAction() { // Log out if (Auth::User()) { $user = new Usernhc(); $user_id = Auth::User()->id; $user_info = $user->getUsernhcById($user_id); $logs = new Logs(); $logs->ip = Request::getClientIp(); $logs->host = Request::root(); $logs->lastpage = ''; $logs->last_visit = date('Y-m-d H:i:s'); $logs->role_id = $user_info[0]->role_id; $logs->data_id = rand(1, 11); $logs->userid = $user_id; $logs->save(); } // Redirect to homepage if (Auth::logout()) { Auth::logout(); return Redirect::to('login')->with('success', 'ออกจากระบบสำเร็จ'); } else { return Redirect::to('login')->with('success', 'ออกจากระบบสำเร็จ'); } }
public function guardarPerfil() { //Campos $nombresApellidos = e(Input::get('nombresApellidos')); $telefono = e(Input::get('telefono')); $edad = e(Input::get('edad')); $correo = e(Input::get('correo')); $genero = e(Input::get('genero')); //Reglas $rules = array('nombresApellidos' => 'required|regex:/^([a-zA-z])/', 'edad' => 'regex:/^([0-9])/', 'telefono' => 'regex:/^([0-9])/', 'correo' => 'regex:/^([a-zA-Z0-9])+@espoch.edu.ec/', 'genero' => 'in:Masculino,Femenino'); //Mensajes $messages = array('required' => 'El campo :attribute es obligatorio', 'correo' => 'El campo :attribute debe ser un email institucional', 'in' => 'Seleccione una opción válida', 'unique' => 'El correo electrónico ya fue registrado'); $validation = Validator::make(Input::all(), $rules, $messages); if ($validation->fails()) { return Redirect::to(URL::previous())->withInput()->withErrors($validation); } else { $usuario = User::find(Auth::User()->id); $usuario->nombres_usuario = $nombresApellidos; $usuario->telefono_usuario = $telefono; $usuario->edad_usuario = $edad; $usuario->correo_usuario = $correo; $usuario->genero_usuario = $genero; $usuario->save(); return Redirect::to(URL::previous())->with('mensaje', 'Perfil Actualizado Corrrectamente'); } }
public function update($id) { if (Auth::id() != $id) { return Redirect::to('http://google.com'); } $user = Auth::User(); $validator = Validator::make(Input::all(false), ['email' => 'required|email|unique:users,email,' . $id, 'password' => 'min:5|confirmed:password_confirmation', 'first_name' => 'required', 'last_name' => 'required']); if ($validator->passes()) { $img_ava = $user->avatar_img; $password = Input::get('password'); if (Input::hasFile('avatar_img')) { if (File::exists(Config::get('user.upload_user_ava_directory') . $img_ava)) { File::delete(Config::get('user.upload_user_ava_directory') . $img_ava); } if (!is_dir(Config::get('user.upload_user_ava_directory'))) { File::makeDirectory(Config::get('user.upload_user_ava_directory'), 0755, true); } $img = Image::make(Input::file('avatar_img')); $img_ava = md5(Input::get('username')) . '.' . Input::file('avatar_img')->getClientOriginalExtension(); if ($img->width() < $img->height()) { $img->resize(100, null, function ($constraint) { $constraint->aspectRatio(); })->crop(100, 100)->save(Config::get('user.upload_user_ava_directory') . $img_ava, 90); } else { $img->resize(null, 100, function ($constraint) { $constraint->aspectRatio(); })->crop(100, 100)->save(Config::get('user.upload_user_ava_directory') . $img_ava, 90); } } $user->update(['username' => null, 'email' => Input::get('email'), 'password' => !empty($password) ? Hash::make($password) : $user->password, 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')]); return Redirect::back()->with('success_msg', Lang::get('messages.successupdate')); } else { return Redirect::back()->withErrors($validator)->withInput(); } }
public static function log($action, $userid = null) { if ($userid == null) { $userid = Auth::User()->id; } DB::table('logs')->insert(array('logs_action' => $action, 'logs_userId' => $userid, 'logs_ip' => $_SERVER["HTTP_CF_CONNECTING_IP"])); }
public function SISA_index() { $rol = Auth::User()->Rol_Id; switch ($rol) { case 1: Session::put('admninistrador', Auth::user()); return Redirect::to('/dsbd'); break; case 2: Session::put('oficialia', Auth::user()); return Redirect::to('/oficialia'); break; case 3: Session::put('direccion', Auth::user()); return Redirect::to('/direccion'); break; case 4: Session::put('subdireccion', Auth::user()); return Redirect::to('/subdireccion'); break; case 5: Session::put('jefatura', Auth::user()); return Redirect::to('/jefatura'); break; case 6: Session::put('iescmpl', Auth::user()); return Redirect::to('/iescmpl'); break; default: return Redirect::to('/login'); break; } }
public function logout() { $user = Auth::User(); $users = $user['u_name']; Auth::logout(); return Redirect::to('index')->with('out', "Goodbye, Welcome Back again!!!!!! " . $users . " "); }
public function index() { $notifications = Notification::where('user', '=', Auth::User()->id)->orderBy('id', 'desc')->take(5)->get(); $count_notification = Notification::where('user', '=', Auth::User()->id)->where('read', '=', 0)->count(); $user_details = array('surname' => Auth::User()->surname, 'name' => Auth::User()->name, 'avatar' => Auth::User()->avatar); $sidebar_adverts = DB::table('adverts')->join('advertisers', 'advertisers.id', '=', 'adverts.advertiser')->where('advertisers.id', '=', Auth::User()->advertiser)->select('adverts.name')->get(); return View::make('profile')->with('user', $user_details)->with('notifications', $notifications)->with('sidebar_adverts', $sidebar_adverts)->with('count_notification', $count_notification); }
public function getDelete($exerciseID) { $exercise = \App\Exercise::find($exerciseID); if ($exercise && $exercise->user_id == \Auth::User()->id) { $exercise->delete(); } return redirect('/user/workouts/exercises'); }
/** * do Logout process. * * @return Response */ public function getLogout() { if (Auth::User()) { Auth::logout(); return Redirect::to($this->loginURL)->with('message', 'User logged out.'); } else { return Redirect::to($this->loginURL)->with('message', 'User not found or password incorrect.'); } }
public function isFavored() { if (!Auth::check()) { return false; } if ($this->belongsToMany('User', 'favorites', 'quote_id', 'user_id')->whereUserId(Auth::User()->id)->count() > 0) { return true; } }
public function logout() { $id = Auth::User()->id; $user = User::find($id); $user->estado_usuario = 0; $user->save(); Auth::logout(); return Redirect::to('/'); }
public function showMCServer($id) { if (count(DB::table('mcservers')->where('mcs_id', '=', $id)->where('mcs_uid', '=', Auth::User()->id)->first())) { $title = settings::get("siteName") . " - Servidor De Minecraft"; return View::make('panel.MCServer')->with('title', $title)->with('id', $id); } else { return Redirect::to(URL::to('/panel/servers')); } }
function right($param) { $arParams = unserialize(Auth::User()->rights); if (!isset($arParams[$param]) or $arParams[$param] == 'no') { return false; } else { return true; } }
public function guardarComentarioModerador() { $moderador = Input::get('moderador'); $silabo = Input::get('silabo'); $contenido = Input::get('contenido'); $input = array('de_comentario' => Auth::User()->id, 'para_comentario' => $moderador, 'detalle_comentario' => $contenido, 'fecha_comentario' => date('Y-m-d G:i:s'), 'silabo_comentario' => $silabo, 'moderador_comentario' => $moderador); Comentario::create($input); $files = DB::select('SELECT id_comentario, de_comentario, para_comentario, detalle_comentario, silabo_comentario, nombres_usuario, genero_usuario, moderador_comentario, silabo.usuario_silabo as usuario from comentario join silabo on comentario.silabo_comentario = silabo.id_silabo join usuario on usuario.id = comentario.moderador_comentario where silabo_comentario ="' . $silabo . '" and detalle_comentario="' . $contenido . '"'); return new JsonResponse($files); }
public function postFachkraft() { $instId = Auth::User()->installateur->id; $input = Input::all(); $fachkraft = Fachkraft::firstOrNew(["installateur_id" => $instId]); $fachkraft->fill($input); $fachkraft->save(); $inst = $this->getInstallateurInstance(); return Redirect::back()->withInst($inst); }
/** * Get the top dragons from the table * * @param [] $table * @param string $which 'fish' or 'wood' * @return array */ protected function getFromTable(&$table, $which) { $dragons = []; $this->sortList($table, $which); for ($i = 0; $i < \Auth::User()->{$which}; $i++) { $dragon = array_shift($table); $dragons[] = $dragon['id']; } return $dragons; }
/** * Checks if the tag is new, and sets the created and modified times appropriately, * prior to saving. * @see testProjectModel::beforeSave() */ public function beforeSave() { if ($this->isNew) { $this->created = date("Y-m-d H:i:s"); $this->modified = $this->created; $this->user = Auth::User()->id; } else { $this->modified = date("Y-m-d H:i:s"); } return true; }
protected function getInstallateurInstance() { $inst = Auth::User()->installateur; if (is_null($inst)) { $inst = new Installateur(); $inst->fachkraft = new Fachkraft(); } elseif (is_null(Auth::User()->installateur->fachkraft)) { $inst->fachkraft = new Fachkraft(); } return $inst; }
public function postTestimonials() { $txt = Input::get('txt'); $getTestimonials = new Testimonials(); $getTestimonials['user_id'] = Auth::User()['id']; $getTestimonials['testimonials'] = $txt; if (!$getTestimonials->save()) { return View::make('testimonials.index')->with('mt', "TESTIMONIALS")->with('alert', 'fail')->with('msg', 'You have failed to created testimonials'); } return View::make('testimonials.index')->with('mt', "TESTIMONIALS")->with('alert', 'success')->with('msg', 'Successfully created testimonials'); }
public function user_contact_sore($id) { $user = User::where('id', $id)->pluck('email'); $user_name_mail = User::where('id', $id)->pluck('user_name'); $login_email = Auth::User()->email; $data = array('email' => $user, 'from' => $login_email); Mail::send('authentications.mails.send', array('user_name' => $user_name_mail, 'messages' => Input::get('messages')), function ($message) use($data) { $message->from($data['from'])->to($data['email'], Input::get('messages'))->subject(Input::get('subject')); }); return Redirect::intended('home'); }
public function infConsulta($array) { $obj = (object) $array; $usuario = Auth::User(); try { $template = new Template('consulta', array('nombre' => $usuario->strNombre, 'apellido' => $usuario->strApellido, 'mensaje' => $obj->descripcion, 'asunto' => $obj->asunto, 'fecha' => date('d/m/Y'), 'empresa' => $obj->strEmpresa)); $this->Body = $template->get(); $this->send(); } catch (Exception $e) { echo $e->getMessage(); } }
public static function submitItems(Request $request, $eid) { $itemlist = json_decode($request->getContent()); $uid = Auth::User()->uid; foreach ($itemlist->items as $item) { $newItem = new EventListItem(); $newItem->uid = $uid; $newItem->eid = $eid; $newItem->description = $item->description; $newItem->save(); } }
public function index() { if (\Auth::User()->type == 'Student') { $dashStudent = new DashboardStudentController(); $periods = $dashStudent->getRegistryPeriods(); return view('Admin.dashboardStudent', ['periods' => $periods]); } else { $dashTeacher = new DashboardTeacherController(); $periods = $dashTeacher->getRegistryPeriods(); return view('Admin.dashboardTeacher', ['periods' => $periods]); } }
public function actualizarSeccion($inputs) { $fecha = new DateTime(); DB::transaction(function () use($inputs, $fecha) { $section = Secciones::where('IdSeccion', $inputs['IdSeccion'])->first(); $section->NombreSeccion = $inputs['new-nombre']; $section->FechaEdicion = $fecha->format('Y-m-d'); $section->EditadoPor = Auth::User()->IdUsuario; $section->save(); }); $Id = DB::table('secciones')->max('IdSeccion'); return $Id; }
public function viewProfile() { $user = Auth::User(); $views = Viewable::viewedResource($user->ID); $username = $user->user_login; $profilePic = userProfilePhoto::where('username', $username)->pluck('photoUrl'); $quiz_attempts = QuizAttempt::ownedAttempts($user->ID)->get(); if (Auth::user()->role == 'admin' || Auth::user()->role == 'teacher') { return View::make('profile.index')->with(array('user' => $user, 'views' => $views, 'quiz_attempts' => $quiz_attempts)); } else { return View::make('profile.index_student')->with(array('user' => $user, 'views' => $views, 'quiz_attempts' => $quiz_attempts, 'photoUrl' => $profilePic)); } }
public function actualizarDescripcion($inputs) { $fecha = new DateTime(); DB::transaction(function () use($inputs, $fecha) { $description = Descripcion::where('Secciones_Id', $inputs['IdSeccion'])->where('SecDeArea', $inputs['IdArea'])->first(); $description->Descripcion = $inputs['set-descripcion']; $description->FechaEdicion = $fecha->format('Y-m-d'); $description->EditadoPor = Auth::User()->IdUsuario; $description->save(); }); $Id = DB::table('secciones')->max('IdSeccion'); return $Id; }
public function checkPoints() { $user = Auth::User(); $ShoppingCart = new ShoppingCart(); $ShoppingCart->all(); $credit = $user->dblCredito; $total = $ShoppingCart->getTotal(); if ($credit - $total < 0) { return false; } else { return true; } }