This commit is contained in:
Meghdad committed 2026-11-26 12:29:14 +03:30
commit 647c8a8cab
236 files changed
+24692

No files matched your search

+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Attributes\Scope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
abstract class LocalizedContent extends Model
{
protected $guarded = ['id'];
protected function casts(): array
{
return ['published_at' => 'datetime'];
}
public function text(string $field, ?string $locale = null): string
{
return $this->getAttribute($field.'_'.($locale ?? app()->getLocale()));
}
#[Scope]
protected function published(Builder $query): void
{
$query->where('published_at', '<=', now());
}
}