當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Auth::id方法代碼示例

本文整理匯總了PHP中App\Http\Requests\Auth::id方法的典型用法代碼示例。如果您正苦於以下問題:PHP Auth::id方法的具體用法?PHP Auth::id怎麽用?PHP Auth::id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在App\Http\Requests\Auth的用法示例。


在下文中一共展示了Auth::id方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: authorize

 /**
  * 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();
 }
開發者ID:spitzgoby,項目名稱:spitzgoby,代碼行數:12,代碼來源:PostRequest.php

示例2: authorize

 /**
  * 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;
 }
開發者ID:boxtar,項目名稱:laratest,代碼行數:25,代碼來源:PostRequest.php

示例3: rules

 /**
  * 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'];
     }
 }
開發者ID:elNapoli,項目名稱:iCnca7CrTNYXRF4oxPSidusv17MoVk7CEAhNGFGcYHSu0DNSy7Hkq,代碼行數:27,代碼來源:CretePostulacionRequest.php

示例4: authorize

 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     return \Auth::id() === $this->route('users')->id;
 }
開發者ID:boxtar,項目名稱:laratest,代碼行數:9,代碼來源:UserRequest.php

示例5: authorize

 /**
  * Determine if the user is authorized to make this request.
  *
  * @return bool
  */
 public function authorize()
 {
     return User::where('id', \Auth::id())->exists();
 }
開發者ID:WangWeigao,項目名稱:m1,代碼行數:9,代碼來源:StoreInstrumentPostRequest.php

示例6: rules

 /**
  * 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'];
 }
開發者ID:charlieboo,項目名稱:creatrip,代碼行數:9,代碼來源:UpdateAccountRequest.php

示例7: authorize

 /**
  * 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();
 }
開發者ID:TyrekeYang,項目名稱:webapp,代碼行數:10,代碼來源:PostRequest.php


注:本文中的App\Http\Requests\Auth::id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。