fialutfiatunnisa

KaryawanRequest.php

May 28th, 2017
210
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 App\Http\Requests\Requests;
  6. use Illuminate\Foundation\Http\FormRequest;
  7.  
  8. class KaryawanRequest extends FormRequest
  9. {
  10.     /**
  11.      * Determine if the user is authorized to make this request.
  12.      *
  13.      * @return bool
  14.      */
  15.     public function authorize()
  16.     {
  17.         return true;
  18.     }
  19.  
  20.     /**
  21.      * Get the validation rules that apply to the request.
  22.      *
  23.      * @return array
  24.      */
  25.     public function rules()
  26.     {
  27.         if($this->method() == 'PATCH'){
  28.             $nip_rule = 'required|numeric|unique:employees,nip,'.$this->get('id');
  29.         } else {
  30.             $nip_rule='required|numeric|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:jpeg,jpg,bmp,png',
  38.           ];
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment