driven breakdown tables, with frontend/cards/dialog updated accordingly (database/ migrations/2025_10_17_000001_add_description_table_to_packages.php, database/ migrations/2025_10_17_000002_add_translation_columns_to_packages.php, database/seeders/PackageSeeder.php, app/ Http/Controllers/MarketingController.php, resources/js/pages/marketing/Packages.tsx). Filament Package resource gains locale tabs, markdown editor, numeric/toggle inputs, and simplified feature management (app/Filament/Resources/PackageResource.php, app/Filament/Resources/PackageResource/Pages/ CreatePackage.php, .../EditPackage.php). Legal pages now render markdown-backed content inside the main layout via a new controller/view route setup and updated footer links (app/Http/Controllers/LegalPageController.php, routes/web.php, resources/views/partials/ footer.blade.php, resources/js/pages/legal/Show.tsx, remove old static pages). Translation files and shared assets updated to cover new marketing/legal strings and styling tweaks (public/ lang/*/marketing.json, resources/lang/*/marketing.php, resources/css/app.css, resources/js/admin/components/ LanguageSwitcher.tsx).
113 lines
2.7 KiB
PHP
113 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
use Illuminate\Database\Eloquent\Casts\Attribute;
|
|
|
|
class Package extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'name',
|
|
'name_translations',
|
|
'slug',
|
|
'type',
|
|
'price',
|
|
'max_photos',
|
|
'max_guests',
|
|
'gallery_days',
|
|
'max_tasks',
|
|
'watermark_allowed',
|
|
'branding_allowed',
|
|
'max_events_per_year',
|
|
'expires_after',
|
|
'features',
|
|
'description',
|
|
'description_translations',
|
|
'description_table',
|
|
];
|
|
|
|
protected $casts = [
|
|
'price' => 'decimal:2',
|
|
'max_photos' => 'integer',
|
|
'max_guests' => 'integer',
|
|
'gallery_days' => 'integer',
|
|
'max_tasks' => 'integer',
|
|
'max_events_per_year' => 'integer',
|
|
'expires_after' => 'datetime',
|
|
'watermark_allowed' => 'boolean',
|
|
'branding_allowed' => 'boolean',
|
|
'features' => 'array',
|
|
'name_translations' => 'array',
|
|
'description_translations' => 'array',
|
|
'description_table' => 'array',
|
|
];
|
|
|
|
|
|
protected function features(): Attribute
|
|
{
|
|
return Attribute::make(
|
|
get: function ($value) {
|
|
if (is_array($value)) {
|
|
return $value;
|
|
}
|
|
|
|
if (is_string($value)) {
|
|
$decoded = json_decode($value, true);
|
|
|
|
if (is_string($decoded)) {
|
|
$decoded = json_decode($decoded, true);
|
|
}
|
|
|
|
if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) {
|
|
return $decoded;
|
|
}
|
|
}
|
|
|
|
return [];
|
|
},
|
|
);
|
|
}
|
|
|
|
|
|
public function eventPackages(): HasMany
|
|
{
|
|
return $this->hasMany(EventPackage::class);
|
|
}
|
|
|
|
public function tenantPackages(): HasMany
|
|
{
|
|
return $this->hasMany(TenantPackage::class);
|
|
}
|
|
|
|
public function packagePurchases(): HasMany
|
|
{
|
|
return $this->hasMany(PackagePurchase::class);
|
|
}
|
|
|
|
public function isEndcustomer(): bool
|
|
{
|
|
return $this->type === 'endcustomer';
|
|
}
|
|
|
|
public function isReseller(): bool
|
|
{
|
|
return $this->type === 'reseller';
|
|
}
|
|
|
|
public function getLimitsAttribute(): array
|
|
{
|
|
return [
|
|
'max_photos' => $this->max_photos,
|
|
'max_guests' => $this->max_guests,
|
|
'gallery_days' => $this->gallery_days,
|
|
'max_tasks' => $this->max_tasks,
|
|
'max_events_per_year' => $this->max_events_per_year,
|
|
];
|
|
}
|
|
}
|