CI Feature / test (push) Successful in 3m32s
Neuer kind 'exercise', Varianten je Fassung, Verwendung (erforderlich/ergänzend) und Variantenauswahl am einbindenden Mitglied; der Stand schreibt nur gewählte Varianten fest. Änderungsnachweis über structure_hash. Formatierte Anleitung im Mitgliederbereich und PDF (Fußzeile, Metadaten, Ausgabenachweis, keine gespeicherten Kopien); Sperre trifft nur das Medium. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
93 lines
2.6 KiB
PHP
93 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Catalog;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
|
|
|
/**
|
|
* Fachliche Materialart (FACH-56 bis FACH-58). Die Bezeichnung ist pflegbar, die Kennung (slug) bleibt nach dem Anlegen
|
|
* fest. Zulässige Objektkontexte bestimmen, wo eine Materialart neu gewählt werden kann; vorhandene Zuordnungen bleiben
|
|
* immer erhalten (siehe EditorialVocabulary).
|
|
*/
|
|
class EditorialContentKind extends Model
|
|
{
|
|
/** Objektkontexte aus dem Fachmodell: Medium (ContentElement), Modul und Programm (Composition), Lizenzartikel. */
|
|
public const CONTEXTS = [
|
|
'medium' => 'Medium',
|
|
'modul' => 'Modul',
|
|
'uebung' => 'Übung',
|
|
'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', 'uebung', '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<EditorialContentKind> $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<int, string>
|
|
*/
|
|
public static function selectOptions(): array
|
|
{
|
|
return static::query()->orderBy('sort_order')->orderBy('id')->pluck('label', 'id')->all();
|
|
}
|
|
}
|