50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Admin\Requests\UserManagement;
|
|
|
|
use Illuminate\Contracts\Validation\ValidationRule;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
/**
|
|
* @property mixed $user
|
|
*/
|
|
class UpdateRequest extends FormRequest
|
|
{
|
|
/**
|
|
* Determine if the user is authorized to make this request.
|
|
*/
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Get the validation rules that apply to the request.
|
|
*
|
|
* @return array<string, ValidationRule|array|string>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
|
|
return [
|
|
'username' => ['string', 'max:255',
|
|
Rule::unique('users', 'username')->ignore($this->user->id),],
|
|
'first_name' => 'string|max:255',
|
|
'last_name' => 'string|max:255',
|
|
'national_id' => ['string', 'max:20',
|
|
Rule::unique('users', 'national_id')->ignore($this->user->id),],
|
|
'password' => 'string|min:8|confirmed',
|
|
'email' => ['email', 'max:255',
|
|
Rule::unique('users', 'email')->ignore($this->user->id),],
|
|
'birth_date' => 'nullable|date',
|
|
'phone_number' => ['string', 'max:20',
|
|
Rule::unique('users', 'phone_number')->ignore($this->user->id),],
|
|
'postal_code' => 'nullable|string|max:20',
|
|
'address' => 'nullable|string|max:1000',
|
|
'province_id' => 'integer|exists:provinces,id',
|
|
'city_id' => 'integer|exists:cities,id',
|
|
];
|
|
}
|
|
}
|