feat(categories): add category retrieval and pagination for tenant-specific products

This commit is contained in:
2026-07-28 12:20:17 -03:00
parent ff9d7728e8
commit 8dc80411d7
14 changed files with 355 additions and 8 deletions

View File

@@ -3,6 +3,7 @@
namespace Database\Seeders;
use App\Domains\Catalog\Models\Category;
use App\Domains\Tenant\Models\Tenant;
use Illuminate\Database\Seeder;
class CategorySeeder extends Seeder
@@ -12,6 +13,12 @@ class CategorySeeder extends Seeder
*/
public function run(): void
{
$tenant = Tenant::query()->where('codigo', 'sonder')->first();
if (! $tenant instanceof Tenant) {
return;
}
$categories = [
'Remeras',
'Pantalones',
@@ -23,8 +30,21 @@ class CategorySeeder extends Seeder
foreach ($categories as $nombre) {
Category::firstOrCreate([
'nombre' => $nombre,
'tenant_code' => null,
'tenant_code' => $tenant->codigo,
]);
}
$indumentaria = Category::updateOrCreate(
[
'nombre' => 'Indumentaria',
'tenant_code' => $tenant->codigo,
],
['categoria_id' => null],
);
Category::query()
->where('nombre', 'Remeras')
->where('tenant_code', $tenant->codigo)
->update(['categoria_id' => $indumentaria->id]);
}
}