feat(entry): implement EntryController, EntryService, and EntryResource for managing entries
This commit is contained in:
@@ -13,7 +13,6 @@ use App\Domains\Catalog\Models\FeaturedGroup;
|
||||
use App\Domains\Catalog\Services\CatalogService;
|
||||
use App\Domains\Tenant\Models\Tenant;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Collection;
|
||||
use RuntimeException;
|
||||
|
||||
class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
@@ -93,9 +92,10 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
'has_tickets' => true,
|
||||
'attribute_codes' => ['event_date'],
|
||||
'multi_select_attribute_codes' => ['event_date'],
|
||||
'variants' => $this->nonEmptySubsets($dateIds)
|
||||
->map(fn (array $ids): array => ['real_stock' => 0, 'event_date_ids' => $ids])
|
||||
->all(),
|
||||
'variants' => [[
|
||||
'real_stock' => 0,
|
||||
'event_date_ids' => $dateIds->all(),
|
||||
]],
|
||||
]);
|
||||
|
||||
FeaturedGroup::query()->create([
|
||||
@@ -128,25 +128,4 @@ class FiestaFutbolInfantilProductSeeder extends Seeder
|
||||
...$data,
|
||||
]);
|
||||
}
|
||||
|
||||
/** @return Collection<int, array<int, int>> */
|
||||
private function nonEmptySubsets(Collection $values): Collection
|
||||
{
|
||||
$items = $values->all();
|
||||
$subsets = collect();
|
||||
|
||||
for ($mask = 1; $mask < (1 << count($items)); $mask++) {
|
||||
$subset = [];
|
||||
foreach ($items as $index => $item) {
|
||||
if (($mask & (1 << $index)) !== 0) {
|
||||
$subset[] = $item;
|
||||
}
|
||||
}
|
||||
$subsets->push($subset);
|
||||
}
|
||||
|
||||
return $subsets
|
||||
->sortBy(fn (array $subset): string => count($subset).':'.implode(',', $subset))
|
||||
->values();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user