File: /home/armgroup/libs/database/seeders/CategorySeeder.php
<?php
namespace Database\Seeders;
use App\Models\Article;
use App\Models\Category;
use App\Models\Contact;
use App\Models\Faq;
use App\Models\Product;
use Illuminate\Database\Seeder;
class CategorySeeder extends Seeder
{
public function run()
{
$c1 = Category::create([
'parent_id' => null,
'type' => Product::class,
'icon' => '',
'name' => 'آشپزخانه',
'slug' => 'آشپزخانه',
'image' => '',
'show_in_index' => false,
'status' => true,
]);
$c2 = Category::create([
'parent_id' => null,
'type' => Product::class,
'icon' => '',
'name' => 'نظافت و شستوشو',
'slug' => 'نظافت-و-شستوشو',
'image' => '',
'show_in_index' => false,
'status' => true,
]);
$c3 = Category::create([
'parent_id' => null,
'type' => Product::class,
'icon' => '',
'name' => 'لوازم جانبی',
'slug' => 'لوازم-جانبی',
'image' => '',
'show_in_index' => false,
'status' => true,
]);
$c4 = Category::create([
'parent_id' => $c1->id,
'type' => Product::class,
'name' => 'پخت پز',
'slug' => 'پخت-پز',
'image' => '',
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
]);
$c5 = Category::create([
'parent_id' => $c1->id,
'type' => Product::class,
'name' => 'تهیه نوشیدنی',
'slug' => 'تهیه-نوشیدنی',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
]);
//..........................
$data = [
[
'parent_id' => $c4->id,
'type' => Product::class,
'name' => 'مایکروویو',
'slug' => 'مایکروویو',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'parent_id' => $c4->id,
'type' => Product::class,
'name' => 'سرخکن',
'slug' => 'سرخکن',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'parent_id' => $c4->id,
'type' => Product::class,
'name' => 'آون توستر',
'slug' => 'آون توستر',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'parent_id' => $c5->id,
'type' => Product::class,
'name' => 'چایساز',
'slug' => 'چایساز',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'parent_id' => $c5->id,
'type' => Product::class,
'name' => 'قهوهساز',
'slug' => 'قهوهساز',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'parent_id' => $c5->id,
'type' => Product::class,
'name' => 'کتری برقی',
'slug' => 'کتری-برقی',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'parent_id' => $c2->id,
'type' => Product::class,
'name' => 'نظافت منزل',
'slug' => 'نظافت-منزل',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'parent_id' => $c2->id,
'type' => Product::class,
'name' => 'شستوشوی لباس',
'slug' => ' شستوشوی-لباس',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'parent_id' => $c3->id,
'type' => Product::class,
'name' => 'جانبی آشپزخانه',
'slug' => 'جانبی-آشپزخانه',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'parent_id' => $c3->id,
'type' => Product::class,
'name' => 'جانبی نظافت',
'slug' => 'جانبی-نظافت',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'parent_id' => null,
'type' => Product::class,
'name' => 'تهویه گرمایش',
'slug' => 'تهویه-گرمایش',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'parent_id' => null,
'type' => Product::class,
'name' => 'بهداشت و مراقبت شخصی',
'slug' => 'بهداشت-و-مراقبت-شخصی',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
//-----------------------------------
[
'parent_id' => null,
'type' => Contact::class,
'name' => 'انتقاد یا پیشنهاد',
'slug' => 'انتقاد-یا-پیشنهاد',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
[
'parent_id' => null,
'type' => Contact::class,
'name' => 'حسابداری و امور مالی',
'slug' => 'حسابداری-و-امور مالی',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
//-----------------------------------
[
'parent_id' => null,
'type' => Article::class,
'name' => 'آموزش',
'slug' => 'آموزش',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
//-----------------------------------
[
'parent_id' => null,
'type' => Faq::class,
'name' => 'عمومی',
'slug' => 'عمومی',
'image' => null,
'show_in_index' => false,
'status' => true,
'created_at' => now(),
'updated_at' => now(),
],
];
Category::insert($data);
}
}