32 lines
1.0 KiB
PHP
32 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Preferences;
|
|
|
|
use App\Http\Requests\ApiFormRequest;
|
|
use App\Services\Preferences\PreferencesOptionsService;
|
|
use Illuminate\Validation\Rule;
|
|
|
|
class PreferencesUpsertRequest extends ApiFormRequest
|
|
{
|
|
public function authorize(): bool
|
|
{
|
|
return $this->user() !== null;
|
|
}
|
|
|
|
public function rules(): array
|
|
{
|
|
$options = app(PreferencesOptionsService::class);
|
|
|
|
return [
|
|
'receive_email_notifications' => ['nullable', 'boolean'],
|
|
'receive_sms_notifications' => ['nullable', 'boolean'],
|
|
'notification_email' => ['nullable', 'boolean'],
|
|
'notification_sms' => ['nullable', 'boolean'],
|
|
'theme' => ['nullable', 'string', Rule::in(['light', 'dark'])],
|
|
'language' => ['nullable', 'string', Rule::in(['en', 'fr', 'es'])],
|
|
'style_color' => ['nullable', 'string', Rule::in($options->styleOptions())],
|
|
'menu_color' => ['nullable', 'string', Rule::in($options->menuOptions())],
|
|
];
|
|
}
|
|
}
|