/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { if ($this->isUpdate()) { return Post::findOrFail($this->get('id'))->user_id == \Auth::id(); } return \Auth::check(); }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { // User Model: $user = $this->route('users'); // Post Model: $post = $this->route('posts'); // Ensure Authenticated User is trying to create/edit their own post if ($user->id === \Auth::id()) { // If a Post exists it means User is trying to edit a Post if ($post) { // Is the Authenticated User the owner of the Post they are trying to edit? // NB: $user and Auth::user() are the same thing as per the initial 'if' check return $post->owner->id === $user->id; } else { // Authenticated User is creating a New Post return true; } } return false; }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $postulante = Postulante::where('user_id', \Auth::id())->first(); $email_personal = ""; $email_institucional = ""; $titulo_profesional = ""; $numero = ""; if ($postulante) { //dd('existe'); $email_personal = "," . $postulante->id; $numero = "," . $postulante->id; $email_institucional = "," . $postulante->id . ',postulante'; } if ($this->get('tipo_estudio') === 'Postgrado') { $titulo_profesional = 'required'; } if ($this->get('procedencia') === 'UACH' and $this->get('tipo_estudio') === 'Pregrado') { return ['apellido_paterno' => 'required', 'apellido_materno' => 'required', 'nombre' => 'required', 'tipo' => 'required', 'numero' => 'required|unique:documento_identidad,numero' . $numero, 'fecha_nacimiento' => 'required', 'sexo' => 'required', 'email_personal' => 'required|unique:postulante,email_personal' . $email_personal, 'telefono' => 'required', 'ciudad' => 'required', 'direccion' => 'required', 'nacionalidad' => 'required', 'como_se_entero' => 'required', 'nivel_de_español' => 'required', 'lugar_nacimiento' => 'required', 'titulo_profesional' => $titulo_profesional, 'tipo_estudio' => 'required', 'procedencia' => 'required', 'email_institucional' => 'required|unique:pre_uach,email_institucional' . $email_institucional, 'grupo_sanguineo' => 'required', 'telefono_2' => 'required', 'ciudad_2' => 'required', 'direccion_2' => 'required']; } else { return ['apellido_paterno' => 'required', 'apellido_materno' => 'required', 'nombre' => 'required', 'tipo' => 'required', 'numero' => 'required|unique:documento_identidad,numero' . $numero, 'fecha_nacimiento' => 'required', 'sexo' => 'required', 'email_personal' => 'required|unique:postulante,email_personal' . $email_personal, 'telefono' => 'required', 'ciudad' => 'required', 'direccion' => 'required', 'nacionalidad' => 'required', 'como_se_entero' => 'required', 'nivel_de_español' => 'required', 'lugar_nacimiento' => 'required', 'titulo_profesional' => $titulo_profesional, 'tipo_estudio' => 'required', 'procedencia' => 'required']; } }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return \Auth::id() === $this->route('users')->id; }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { return User::where('id', \Auth::id())->exists(); }
/** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return ['first_name' => 'required|max:100', 'last_name' => 'required|max:100', 'email' => 'required|max:255|email|unique:user,email,' . \Auth::id(), 'gender' => 'required|in:female,male', 'birthdate_submit' => 'required|date', 'phone' => 'max:15']; }
/** * Determine if the user is authorized to make this request. * * @return bool */ public function authorize() { $id = $this->route('id'); return Comment::where('id', $id)->where('user_id', \Auth::id())->exists(); }