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

42 lines
928 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
{
/**
* 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()
{
2021-10-27 05:27:47 +00:00
$rules = [
2020-02-20 07:14:00 +00:00
'name' => 'required',
'email' => 'email|unique:admins,email',
2020-08-20 07:16:43 +00:00
'password' => 'nullable',
'password_confirmation' => 'nullable|required_with:password|same:password',
2020-02-20 07:14:00 +00:00
'status' => 'sometimes',
2020-03-04 06:32:53 +00:00
'role_id' => 'required',
2018-07-02 09:29:27 +00:00
];
2018-12-18 10:44:21 +00:00
if ($this->method() == 'PUT') {
2021-10-27 05:27:47 +00:00
$rules['email'] = 'email|unique:admins,email,' . $this->route('id');
2018-07-02 09:29:27 +00:00
}
2021-10-27 05:27:47 +00:00
return $rules;
2018-07-02 09:29:27 +00:00
}
}