1
0

Removed hard-coded values

This commit is contained in:
Richard Dern 2024-04-18 00:43:53 +02:00
parent 5b9f4eeead
commit 70cba29d45
2 changed files with 24 additions and 13 deletions

View File

@ -2,6 +2,7 @@
namespace App\Services\BundleCreator\Creators;
use App\Classes\Bundle;
use App\Services\BundleCreator\Creators\CollectibleCreators\LegoBundleCreator;
use Illuminate\Filesystem\FilesystemAdapter;
@ -9,6 +10,8 @@
class CollectibleBundleCreator extends BaseBundleCreator
{
private static string $section = 'collections';
public static $bundleCreators = [
LegoBundleCreator::class,
];
@ -44,11 +47,14 @@ public function formSpecs(): ?array
private function listBrands()
{
$brands = [
'lego' => 'LEGO',
'matchbox' => 'matchbox',
'schleich' => 'Schleich',
];
$bundles = Bundle::findBundles($this->disk, static::$section);
$brands = [];
foreach ($bundles as $bundle) {
$brands[basename($bundle->getPath())] = $bundle->metadata()->get('title');
}
asort($brands, SORT_NATURAL);
return $brands;
}
@ -59,6 +65,6 @@ private function listBrands()
*/
public static function handles(string $section, ?array $data = []): bool
{
return $section === 'collections';
return $section === static::$section;
}
}

View File

@ -2,6 +2,7 @@
namespace App\Services\BundleCreator\Creators;
use App\Classes\Bundle;
use Illuminate\Filesystem\FilesystemAdapter;
use function Laravel\Prompts\select;
@ -9,6 +10,8 @@
class CriticBundleCreator extends BaseBundleCreator
{
private static string $section = 'critiques';
public function __construct(protected ?array $data, protected FilesystemAdapter $disk)
{
//
@ -51,12 +54,14 @@ public function formSpecs(): ?array
private function listKinds()
{
$kinds = [
'Film' => 'films',
'Série TV' => 'series',
'Jeu vidéo' => 'jeux-video',
'Livre' => 'livres',
];
$bundles = Bundle::findBundles($this->disk, static::$section);
$kinds = [];
foreach ($bundles as $bundle) {
$kinds[basename($bundle->getPath())] = $bundle->metadata()->get('title');
}
asort($kinds, SORT_NATURAL);
return $kinds;
}
@ -67,6 +72,6 @@ private function listKinds()
*/
public static function handles(string $section, ?array $data = []): bool
{
return $section === 'critiques';
return $section === static::$section;
}
}