42 lines
928 B
PHP
Executable File
42 lines
928 B
PHP
Executable File
<?php
|
|
|
|
namespace Webkul\User\Http\Requests;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UserForm extends FormRequest
|
|
{
|
|
/**
|
|
* 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()
|
|
{
|
|
$rules = [
|
|
'name' => 'required',
|
|
'email' => 'email|unique:admins,email',
|
|
'password' => 'nullable',
|
|
'password_confirmation' => 'nullable|required_with:password|same:password',
|
|
'status' => 'sometimes',
|
|
'role_id' => 'required',
|
|
];
|
|
|
|
if ($this->method() == 'PUT') {
|
|
$rules['email'] = 'email|unique:admins,email,' . $this->route('id');
|
|
}
|
|
|
|
return $rules;
|
|
}
|
|
}
|