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>
46 lines
1.2 KiB
PHP
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();
|
|
}
|
|
}
|