sarga/packages/Webkul/User/src/Http/Requests/UserForm.php

43 lines
890 B
PHP
Raw Normal View History

2018-07-02 09:29:27 +00:00
<?php
namespace Webkul\User\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class UserForm extends FormRequest
{
protected $rules;
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
$this->rules = [
2020-02-20 07:14:00 +00:00
'name' => 'required',
'email' => 'email|unique:admins,email',
2018-07-02 09:29:27 +00:00
'password' => 'nullable|confirmed',
2020-02-20 07:14:00 +00:00
'status' => 'sometimes',
'role_id' => 'required'
2018-07-02 09:29:27 +00:00
];
2018-12-18 10:44:21 +00:00
if ($this->method() == 'PUT') {
2018-07-02 09:29:27 +00:00
$this->rules['email'] = 'email|unique:admins,email,' . $this->route('id');
}
return $this->rules;
}
}