baktinurwahyudin

KaryawanRequest.php

May 27th, 2017
713
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 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.       if($this->method() == "PATCH"){
  29.         $nip_rule = 'required|numeric|unique:employees,nip,'.$this->get('id');
  30.       }else{
  31.         $nip_rule = 'required|numeric|unique:employees,nip';
  32.       }
  33.         return [
  34.           'nip' => $nip_rule,
  35.           'nama' => 'required|string|max:35|min:5',
  36.           'tgl_lahir' => 'required|date',
  37.           'gender' => 'required|in:L,P',
  38.           'foto' => 'sometimes|image|max:500|mimes:jpeg,jpg,bmp,png',
  39.         ];
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment