Files
laraundfelix/app/Domain/Catalog/EditorialDimension.php
T
LarsandCursor 7b325f0d66
CI Feature / test (push) Successful in 53s
Deploy Test / test (push) Successful in 48s
Deploy Test / deploy (push) Successful in 22s
Lasse Präsentationsmedien ohne Inhaltsfassung zu.
Bilder, Filme und Hörstücke lassen sich zuordnen und für die Website freigeben, ohne eine fachliche Fassung anzulegen. Unterrichtsfilme behalten die Teaserfassung an ihrer bereitgestellten Fassung.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-19 08:20:35 +01:00

46 lines
1.2 KiB
PHP

<?php
namespace App\Domain\Catalog;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class EditorialDimension extends Model
{
protected $fillable = ['slug', 'label'];
public function values(): HasMany
{
return $this->hasMany(EditorialDimensionValue::class);
}
/**
* Inhaltselemente pflegen Themen über die Säulen, nicht noch einmal über die Dimension.
* Module, Programme und Lizenzartikel haben keine Säulenauswahl und behalten die Dimension.
*
* @return Collection<int, self>
*/
public static function forSubject(Model $subject): Collection
{
$query = static::query()->with('values')->orderBy('label');
if ($subject instanceof ContentElement) {
$query->where('slug', '!=', 'saeule');
}
return $query->get();
}
/**
* @return list<int>
*/
public static function offeredValueIds(Model $subject): array
{
return static::forSubject($subject)
->flatMap(fn (self $dimension) => $dimension->values->pluck('id'))
->map(fn ($id): int => (int) $id)
->all();
}
}