Advertisement
muza_sm183

KaryawanRequest

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