43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http;
|
|
|
|
use App\Domain\Catalog\CompositionKind;
|
|
use App\Domain\Catalog\LicenseArticle;
|
|
|
|
class CourseOutline
|
|
{
|
|
public function title(LicenseArticle $article): string
|
|
{
|
|
$release = $article->currentRelease;
|
|
|
|
if ($release === null) {
|
|
return $article->code;
|
|
}
|
|
|
|
$release->loadMissing([
|
|
'rootCompositionVersion.composition',
|
|
'rootElementVersion.element',
|
|
]);
|
|
|
|
return $release->rootCompositionVersion?->composition?->designation
|
|
?? $release->rootElementVersion?->element?->working_title
|
|
?? $release->classification_note
|
|
?? $article->code;
|
|
}
|
|
|
|
public function kindLabel(LicenseArticle $article): ?string
|
|
{
|
|
$release = $article->currentRelease;
|
|
|
|
if ($release === null) {
|
|
return null;
|
|
}
|
|
|
|
$release->loadMissing('rootCompositionVersion.composition');
|
|
$kind = $release->rootCompositionVersion?->composition?->kind;
|
|
|
|
return $kind instanceof CompositionKind ? $kind->label() : null;
|
|
}
|
|
}
|