Add (categories)
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->nullable();
|
||||
$table->boolean('enabled')->default(true);
|
||||
$table->timestamps();
|
||||
$table->nestedSet();
|
||||
$table->index(['name', 'slug']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('categories');
|
||||
}
|
||||
};
|
||||
113
database/seeders/CategorySeeder.php
Normal file
113
database/seeders/CategorySeeder.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
use App\Models\Category;
|
||||
|
||||
class CategorySeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$categories = [
|
||||
['name' => 'Automotive'],
|
||||
[
|
||||
'name' => 'Business',
|
||||
'children' => [
|
||||
['name' => 'Trading'],
|
||||
['name' => 'Information Technology'],
|
||||
['name' => 'Marketing'],
|
||||
['name' => 'Office'],
|
||||
['name' => 'Telecommunications']
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'Entertainment',
|
||||
'children' => [
|
||||
['name' => 'Dating'],
|
||||
['name' => 'Film & Television'],
|
||||
['name' => 'Games & Toys'],
|
||||
['name' => 'Music and Video'],
|
||||
['name' => 'Adult Entertainment']
|
||||
]
|
||||
],
|
||||
['name' => 'Food & Drink'],
|
||||
[
|
||||
'name' => 'Hobbies & Gifts',
|
||||
'children' => [
|
||||
['name' => 'Collectibles'],
|
||||
['name' => 'Pets'],
|
||||
['name' => 'Photography'],
|
||||
['name' => 'Hunting & Fishing']
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'Education',
|
||||
'children' => [
|
||||
['name' => 'Languages']
|
||||
]
|
||||
],
|
||||
['name' => 'Law'],
|
||||
['name' => 'Politics'],
|
||||
[
|
||||
'name' => 'Shopping',
|
||||
'children' => [
|
||||
['name' => 'Home & Garden'],
|
||||
['name' => 'Clothing & Accessories'],
|
||||
['name' => 'Computer & Electronics']
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'Religion & Spirituality',
|
||||
'children' => [
|
||||
['name' => 'Holistic Health']
|
||||
]
|
||||
],
|
||||
['name' => 'Real Estate'],
|
||||
['name' => 'Social Networks'],
|
||||
[
|
||||
'name' => 'Society',
|
||||
'children' => [
|
||||
['name' => 'Family'],
|
||||
['name' => 'Wedding'],
|
||||
['name' => 'Immigration']
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'Wellness',
|
||||
'children' => [
|
||||
['name' => 'Health & Beauty'],
|
||||
['name' => 'Psychology & Psychotherapy']
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'Tips & Tricks',
|
||||
'children' => [
|
||||
['name' => 'How to']
|
||||
]
|
||||
],
|
||||
[
|
||||
'name' => 'Travel',
|
||||
'children' => [
|
||||
['name' => 'Holiday'],
|
||||
['name' => 'World Festivals'],
|
||||
['name' => 'Outdoors']
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
foreach ($categories as $category)
|
||||
{
|
||||
$node = Category::create($category);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user