Advertisement
Guest User

KaryawanController.php

a guest
May 27th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.92 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.     public function rules()
  22.     {
  23.         //cek create atau update
  24.         if($this->method() == 'PATCH'){
  25.             $nip_rule='required|numeric|digits:5|unique:employees,nip,'.$this->get('id');
  26.         }else{
  27.             $nip_rule='required|numeric|digits:5|unique:employees,nip';
  28.         }
  29.         return [
  30.             'nip'=> $nip_rule,
  31.             'nama'=>'required|string|max:35|min:5',
  32.             'tgl_lahir'=>'required|date',
  33.             'gender'=>'required|in:L,P',
  34.             'foto' => 'sometimes|image|mimes:jpeg,jpg,bmp,png|max:500',
  35.         ];
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement