mirror of
https://github.com/crater-invoice/crater.git
synced 2025-12-15 09:52:55 -05:00
build version 400
This commit is contained in:
59
app/Http/Requests/UserRequest.php
Normal file
59
app/Http/Requests/UserRequest.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace Crater\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class UserRequest 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' => [
|
||||
'required',
|
||||
'email',
|
||||
Rule::unique('users')
|
||||
],
|
||||
'phone' => [
|
||||
'nullable'
|
||||
],
|
||||
'password' => [
|
||||
'required',
|
||||
'min:8'
|
||||
]
|
||||
];
|
||||
|
||||
if ($this->getMethod() == 'PUT') {
|
||||
$rules['email'] = [
|
||||
'required',
|
||||
'email',
|
||||
Rule::unique('users')->ignore($this->user)
|
||||
];
|
||||
$rules['password'] = [
|
||||
'nullable',
|
||||
'min:8'
|
||||
];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user