- lang/fa: add validation/auth/passwords/pagination translations so admin and API validation errors are in Persian - templates: soft-delete instead of cascade-deleting their generations; keep resolving trashed template on generations (labels/downloads) - templates: add TemplateInfolist with a real thumbnail ImageEntry - generations: auto-name template-based generations and use that name for the download file and as a searchable column - admin: show all dates as Jalali via ->jalaliDate()/->jalaliDateTime() Filament macros (App\Support\Jalali) - wallets: harden the deposit/withdraw action to surface the exact error instead of a 500 - profile: normalize Iranian mobile numbers (App\Support\Mobile), add social_links, coerce notification-preference booleans, require the current password to delete an account Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013P66ea1dC5CVM9t29496t5
63 lines
1.4 KiB
PHP
63 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Requests\Api;
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
class UpdateNotificationPreferencesRequest extends FormRequest
|
|
{
|
|
/**
|
|
* @var list<string>
|
|
*/
|
|
private const FIELDS = [
|
|
'comment_on_presentation',
|
|
'form_reply',
|
|
'new_follower',
|
|
'news_announcements',
|
|
'weekly_product_updates',
|
|
'weekly_blog_digest',
|
|
];
|
|
|
|
public function authorize(): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* Accept "true"/"false"/"1"/"0"/1/0 strings from the frontend and coerce them to
|
|
* real booleans before validation so the toggles actually persist.
|
|
*/
|
|
protected function prepareForValidation(): void
|
|
{
|
|
$normalized = [];
|
|
|
|
foreach (self::FIELDS as $field) {
|
|
if ($this->has($field)) {
|
|
$normalized[$field] = filter_var($this->input($field), FILTER_VALIDATE_BOOL, FILTER_NULL_ON_FAILURE) ?? false;
|
|
}
|
|
}
|
|
|
|
if ($normalized !== []) {
|
|
$this->merge($normalized);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function rules(): array
|
|
{
|
|
return array_fill_keys(self::FIELDS, ['sometimes', 'boolean']);
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public function messages(): array
|
|
{
|
|
return [
|
|
'*.boolean' => 'مقدار این تنظیم باید بله یا خیر باشد.',
|
|
];
|
|
}
|
|
}
|