Advertisement
Firdaus_Shinoda

KaryawanRequest.php

May 27th, 2017
2,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Http\Requests;
  4.  
  5. use Illuminate\Foundation\Http\FormRequest;
  6.  
  7. class KaryawanRequest extends FormRequest
  8. {
  9.     /**
  10.      * Determine if the user is authorized to make this request.
  11.      *
  12.      * @return bool
  13.      */
  14.     public function authorize()
  15.     {
  16.         return true;
  17.     }
  18.  
  19.     /**
  20.      * Get the validation rules that apply to the request.
  21.      *
  22.      * @return array
  23.      */
  24.     public function rules()
  25.     {
  26.         //cek create atau update
  27.         if ($this->method() == 'PATCH') {
  28.           $nip_rule = 'required|string|size:5|unique:employees,nip'.$this->get('id');
  29.         } else {
  30.           $nip_rule = 'required|string|size:5|unique:employees,nip';
  31.         }
  32.         return [
  33.           'nip'=>$nip_rule,
  34.           'nama'=>'required|string|max:35|min:5',
  35.           'tgl_lahir'=>'required|date',
  36.           'gender'=>'required|in:L,P',
  37.           'foto'=>'sometimes|image|max:500|mimes:jpg,jpeg,bmp,png,JPG,JPEG,PNG',
  38.         ];
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement