epung

KaryawanRequest.php

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