Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace App\Http\Requests;
- use App\Http\Requests\Request;
- use Illuminate\Foundation\Http\FormRequest;
- class KaryawanRequest extends FormRequest
- {
- /**
- * Determine if the user is authorized to make this request.
- *
- * @return bool
- */
- public function authorize()
- {
- return true;
- }
- public function rules()
- {
- //cek create atau update
- if($this->method() == 'PATCH'){
- $nip_rule='required|numeric|digits:5|unique:employees,nip,'.$this->get('id');
- }else{
- $nip_rule='required|numeric|digits:5|unique:employees,nip';
- }
- return [
- 'nip'=> $nip_rule,
- 'nama'=>'required|string|max:35|min:5',
- 'tgl_lahir'=>'required|date',
- 'gender'=>'required|in:L,P',
- 'foto' => 'sometimes|image|mimes:jpeg,jpg,bmp,png|max:500',
- ];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement