- 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
71 lines
1.5 KiB
PHP
71 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Attributes\Fillable;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
|
|
#[Fillable([
|
|
'category_id',
|
|
'title',
|
|
'slug',
|
|
'description',
|
|
'file_path',
|
|
'thumbnail_path',
|
|
'is_active',
|
|
'is_ai_enabled',
|
|
'ai_repeatable_slide_number',
|
|
'created_by',
|
|
])]
|
|
class Template extends Model
|
|
{
|
|
use SoftDeletes;
|
|
|
|
/**
|
|
* @return BelongsTo<Category, $this>
|
|
*/
|
|
public function category(): BelongsTo
|
|
{
|
|
return $this->belongsTo(Category::class);
|
|
}
|
|
|
|
/**
|
|
* @return BelongsTo<User, $this>
|
|
*/
|
|
public function creator(): BelongsTo
|
|
{
|
|
return $this->belongsTo(User::class, 'created_by');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<TemplateKey, $this>
|
|
*/
|
|
public function keys(): HasMany
|
|
{
|
|
return $this->hasMany(TemplateKey::class)->orderBy('sort_order');
|
|
}
|
|
|
|
/**
|
|
* @return HasMany<TemplateGeneration, $this>
|
|
*/
|
|
public function generations(): HasMany
|
|
{
|
|
return $this->hasMany(TemplateGeneration::class)->latest();
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'is_active' => 'boolean',
|
|
'is_ai_enabled' => 'boolean',
|
|
'ai_repeatable_slide_number' => 'integer',
|
|
];
|
|
}
|
|
}
|