hasComposition()

* renderRegion()
* draft and published-state handling
* document and placement scheduling
* disabled-placement filtering
* ordered region rendering
* safe fallback when composition tables or document views are missing
* compatibility with common alternative column names
This commit is contained in:
Mark Gregory
2026-07-27 09:43:42 +01:00
parent a211b10e29
commit c972808d0a
22 changed files with 455 additions and 754 deletions
+6 -5
View File
@@ -1,17 +1,18 @@
<?php
declare(strict_types=1);
namespace Modules\Content\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
final class ContentDocument extends Model
{
use SoftDeletes;
protected $fillable = ['content_type_id','title','slug','data','status','published_at','expires_at','language','created_by','updated_by'];
protected function casts(): array { return ['data'=>'array','published_at'=>'datetime','expires_at'=>'datetime']; }
protected $fillable = ['content_type_id','title','slug','status','data','published_at','expires_at'];
protected $casts = ['data'=>'array','published_at'=>'datetime','expires_at'=>'datetime'];
public function type(): BelongsTo { return $this->belongsTo(ContentType::class, 'content_type_id'); }
public function placements(): HasMany { return $this->hasMany(PageContent::class); }
public function scopePublished($query) { return $query->where('status','published')->where(fn($q) => $q->whereNull('published_at')->orWhere('published_at','<=',now()))->where(fn($q) => $q->whereNull('expires_at')->orWhere('expires_at','>',now())); }
}