feat(seeders): Add slug generation for brands and categories in their respective seeders for improved URL handling.

This commit is contained in:
Yoga Pangestu 2025-12-14 16:39:52 +07:00
parent 06921096ba
commit 307cdeec44
2 changed files with 4 additions and 0 deletions

View File

@ -4,6 +4,7 @@
use App\Models\Brand; use App\Models\Brand;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
class BrandSeeder extends Seeder class BrandSeeder extends Seeder
{ {
@ -25,6 +26,7 @@ public function run(): void
foreach ($brands as $brand) { foreach ($brands as $brand) {
Brand::create([ Brand::create([
'name' => $brand['name'], 'name' => $brand['name'],
'slug' => Str::slug($brand['name']),
'sort_order' => $brand['sort_order'], 'sort_order' => $brand['sort_order'],
]); ]);
} }

View File

@ -4,6 +4,7 @@
use App\Models\Category; use App\Models\Category;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Str;
class CategorySeeder extends Seeder class CategorySeeder extends Seeder
{ {
@ -25,6 +26,7 @@ public function run(): void
foreach ($categories as $category) { foreach ($categories as $category) {
Category::create([ Category::create([
'name' => $category['name'], 'name' => $category['name'],
'slug' => Str::slug($category['name']),
'description' => $category['description'], 'description' => $category['description'],
'sort_order' => $category['sort_order'], 'sort_order' => $category['sort_order'],
]); ]);