Dieselbe Liste trägt die öffentliche Seite. Medien bleiben privat, Seiten können mehreren Säulen zugeordnet sein. Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.1 KiB
PHP
51 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Catalog;
|
|
|
|
use App\Domain\Cms\Page;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
|
|
|
class Pillar extends Model
|
|
{
|
|
protected $fillable = [
|
|
'name',
|
|
'slug',
|
|
'public_summary',
|
|
'sort_order',
|
|
'published_at',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'published_at' => 'datetime',
|
|
];
|
|
}
|
|
|
|
public function elements(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(ContentElement::class);
|
|
}
|
|
|
|
public function pages(): BelongsToMany
|
|
{
|
|
return $this->belongsToMany(Page::class);
|
|
}
|
|
|
|
/**
|
|
* @param Builder<Pillar> $query
|
|
* @return Builder<Pillar>
|
|
*/
|
|
public function scopePublished(Builder $query): Builder
|
|
{
|
|
return $query->whereNotNull('published_at')->orderBy('sort_order')->orderBy('name');
|
|
}
|
|
|
|
public function publicUrl(): string
|
|
{
|
|
return route('theme', ['slug' => $this->slug]);
|
|
}
|
|
}
|