mirror of
https://github.com/10h30/Test-Laravel-Auth-Basics.git
synced 2026-06-05 15:07:43 +09:00
32 lines
764 B
PHP
32 lines
764 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Requests;
|
||
|
|
|
||
|
|
use Illuminate\Validation\Rule;
|
||
|
|
use Illuminate\Support\Facades\Auth;
|
||
|
|
use Illuminate\Foundation\Http\FormRequest;
|
||
|
|
|
||
|
|
class ProfileUpdateRequest extends FormRequest
|
||
|
|
{
|
||
|
|
public function rules()
|
||
|
|
{
|
||
|
|
return [
|
||
|
|
'name' => ['required', 'string', 'max:255'],
|
||
|
|
'email' => ['required', 'email', 'string', 'max:255', Rule::unique('users')->ignore(Auth::user())],
|
||
|
|
'password' => ['sometimes', 'required_with:old_password', 'string', 'confirmed', 'min:8'],
|
||
|
|
];
|
||
|
|
}
|
||
|
|
|
||
|
|
public function authorize()
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
protected function prepareForValidation()
|
||
|
|
{
|
||
|
|
if ($this->password == null) {
|
||
|
|
$this->request->remove('password');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|