Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php
  2.  
  3. namespace App\Http\Requests;
  4.  
  5. use App\Http\Request\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|unique:employes,nip'.$this->get('id');
  31.         } else{
  32.             $nip_rule='required|string|unique:employes,nip';
  33.         }
  34.         return [
  35.             'nip'=> $nip_rule,
  36.             'nama'=>'required|string|max:35|min:5',
  37.             'tgl_lahir'=>'required|date',
  38.             'gender'=>'required|in:L,P',
  39.             'foto'=> 'sometimes|image|max:500|mimes:jpeg,jpg,bmp,png',
  40.         ];
  41.     }
  42. }