cms/app/Http/Requests/Admin/Profile/UpdateProfileRequest.php

43 lines
1.1 KiB
PHP
Raw Permalink Normal View History

<?php
namespace App\Http\Requests\Admin\Profile;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Auth;
class UpdateProfileRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return auth()->check();
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
*/
public function rules(): array
{
$user = $this->user();
return [
'name' => ['required', 'string', 'max:255'],
'email' => [
'required',
'string',
'lowercase',
'email',
'max:255',
Rule::unique('users')->ignore($user->id),
],
'current_password' => ['nullable', 'required_with:new_password', 'current_password'],
'new_password' => ['nullable', 'string', 'min:8', 'confirmed'],
];
}
}