101 lines
2.9 KiB
PHP
101 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Support;
|
|
|
|
use App\Domain\Catalog\Bundle;
|
|
use App\Domain\Catalog\BundleStatus;
|
|
use App\Domain\Catalog\BundleVersion;
|
|
use App\Domain\Catalog\Composition;
|
|
use App\Domain\Catalog\CompositionVersion;
|
|
use App\Domain\Catalog\ContentElement;
|
|
use App\Domain\Catalog\ContentElementVersion;
|
|
use App\Domain\Catalog\ContentVersionStatus;
|
|
use App\Domain\Catalog\LicenseArticle;
|
|
use App\Domain\Catalog\Offer;
|
|
use App\Domain\Catalog\RightsProfileVersion;
|
|
|
|
class CatalogOptions
|
|
{
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public static function elements(): array
|
|
{
|
|
return ContentElement::query()->orderBy('working_title')->pluck('working_title', 'id')->all();
|
|
}
|
|
|
|
/**
|
|
* @return array<string, string>
|
|
*/
|
|
public static function readyTargets(): array
|
|
{
|
|
$options = [];
|
|
|
|
foreach (ContentElementVersion::query()->where('status', ContentVersionStatus::Bereit)->with('element')->orderBy('id')->get() as $version) {
|
|
$options['element:'.$version->id] = $version->element->working_title.' · Fassung '.$version->number;
|
|
}
|
|
|
|
foreach (CompositionVersion::query()->where('status', ContentVersionStatus::Bereit)->with('composition')->orderBy('id')->get() as $version) {
|
|
$options['composition:'.$version->id] = $version->composition->designation.' · Fassung '.$version->number;
|
|
}
|
|
|
|
return $options;
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public static function compositions(): array
|
|
{
|
|
return Composition::query()->orderBy('designation')->pluck('designation', 'id')->all();
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public static function articles(): array
|
|
{
|
|
return LicenseArticle::query()->orderBy('code')->pluck('code', 'id')->all();
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public static function bundles(): array
|
|
{
|
|
return Bundle::query()->orderBy('name')->pluck('name', 'id')->all();
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public static function bundleVersions(): array
|
|
{
|
|
return BundleVersion::query()
|
|
->where('status', BundleStatus::Veroeffentlicht)
|
|
->with('bundle')
|
|
->orderBy('id')
|
|
->get()
|
|
->mapWithKeys(fn (BundleVersion $version): array => [$version->id => $version->bundle->name.' · Fassung '.$version->number])
|
|
->all();
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public static function rights(): array
|
|
{
|
|
return RightsProfileVersion::query()->with('profile')->orderBy('id')->get()
|
|
->mapWithKeys(fn (RightsProfileVersion $version): array => [$version->id => $version->profile->name.' · '.$version->purpose])
|
|
->all();
|
|
}
|
|
|
|
/**
|
|
* @return array<int, string>
|
|
*/
|
|
public static function offers(): array
|
|
{
|
|
return Offer::query()->orderBy('name')->pluck('name', 'id')->all();
|
|
}
|
|
}
|