feat: Persian panel/API fixes and structural-model tweaks
- 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
This commit is contained in:
@@ -6,23 +6,57 @@ 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 [
|
||||
'comment_on_presentation' => ['sometimes', 'boolean'],
|
||||
'form_reply' => ['sometimes', 'boolean'],
|
||||
'new_follower' => ['sometimes', 'boolean'],
|
||||
'news_announcements' => ['sometimes', 'boolean'],
|
||||
'weekly_product_updates' => ['sometimes', 'boolean'],
|
||||
'weekly_blog_digest' => ['sometimes', 'boolean'],
|
||||
'*.boolean' => 'مقدار این تنظیم باید بله یا خیر باشد.',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user