Files
laraundfelix/app/Domain/Catalog/Pillar.php
LarsandCursor 8cd382c357
Deploy Test / test (push) Successful in 15s
Deploy Test / deploy (push) Successful in 22s
Veröffentliche fachliche Säulen als Themenbereiche der Website.
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>
2026-11-15 11:46:48 +01:00

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]);
}
}