53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Admin\Account;
|
|
|
|
use App\Enums\Gender;
|
|
use App\Rules\PhoneNumber;
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class UpdateProfileRequest extends FormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return auth()->check();
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return [
|
|
'email' => ['required', 'email', 'max:100', Rule::unique('users', 'email')->ignore($this->user()?->id)],
|
|
'username' => ['required', 'string', 'max:20', 'alpha_dash', Rule::unique('users', 'username')->ignore($this->user()?->id)],
|
|
'full_name' => ['required', 'string', 'max:200'],
|
|
'phone_number' => ['nullable', 'string', 'max:20', new PhoneNumber],
|
|
'gender' => ['nullable', Rule::enum(Gender::class)],
|
|
'birth_date' => ['nullable', 'date', 'before:today'],
|
|
'address' => ['nullable', 'string'],
|
|
'profile_photo' => ['nullable', 'image', 'mimes:jpg,jpeg,png,webp', 'max:2048'],
|
|
'remove_profile_photo_ids' => ['nullable', 'array'],
|
|
'remove_profile_photo_ids.*' => ['integer'],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function attributes(): array
|
|
{
|
|
return [
|
|
'email' => 'email',
|
|
'username' => 'username',
|
|
'full_name' => 'nama lengkap',
|
|
'phone_number' => 'nomor telepon',
|
|
'gender' => 'jenis kelamin',
|
|
'birth_date' => 'tanggal lahir',
|
|
'address' => 'alamat',
|
|
'profile_photo' => 'foto profil',
|
|
];
|
|
}
|
|
}
|