'Medium', 'modul' => 'Modul', 'programm' => 'Programm', 'lizenzartikel' => 'Lizenzartikel', ]; /** * Kennungen, auf die der Code fachlich verweist: öffentliche Programmseiten und das Anlegen von Programmen und * Modulen (programm, modul), Vertraulichkeit von Traineranleitungen (traineranleitung). Ihre Bezeichnung bleibt * pflegbar; deaktivieren, Kontexte ändern und löschen sind gesperrt. */ public const SYSTEM_SLUGS = ['programm', 'modul', 'traineranleitung']; protected $fillable = [ 'slug', 'label', 'sort_order', 'is_active', 'contexts', ]; protected function casts(): array { return [ 'is_active' => 'boolean', 'contexts' => 'array', 'sort_order' => 'integer', ]; } public function compositions(): HasMany { return $this->hasMany(Composition::class); } public function contentElements(): HasMany { return $this->hasMany(ContentElement::class); } public function licenseArticles(): HasMany { return $this->hasMany(LicenseArticle::class); } /** * @param Builder $query */ public function scopeActive(Builder $query): void { $query->where('is_active', true); } public function allows(string $context): bool { return in_array($context, (array) ($this->contexts ?? []), true); } public function isSystem(): bool { return in_array($this->slug, self::SYSTEM_SLUGS, true); } /** * Alle Materialarten in Pflegereihenfolge (ohne Kontext- oder Aktivfilter). Für Auswahlstellen gilt * EditorialVocabulary. * * @return array */ public static function selectOptions(): array { return static::query()->orderBy('sort_order')->orderBy('id')->pluck('label', 'id')->all(); } }