Database Seeder
This commit is contained in:
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use App\Models\Color;
|
||||||
|
|
||||||
|
class ColorSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
// Seed Random Colors
|
||||||
|
$colors = [
|
||||||
|
['name' => 'Red', 'hex' => '#FF0000'],
|
||||||
|
['name' => 'Green', 'hex' => '#00FF00'],
|
||||||
|
['name' => 'Blue', 'hex' => '#0000FF'],
|
||||||
|
['name' => 'Yellow', 'hex' => '#FFFF00'],
|
||||||
|
['name' => 'Orange', 'hex' => '#FFA500'],
|
||||||
|
['name' => 'Purple', 'hex' => '#800080'],
|
||||||
|
['name' => 'Pink', 'hex' => '#FFC0CB'],
|
||||||
|
['name' => 'Brown', 'hex' => '#A52A2A'],
|
||||||
|
['name' => 'Gray', 'hex' => '#808080'],
|
||||||
|
['name' => 'Black', 'hex' => '#000000'],
|
||||||
|
['name' => 'White', 'hex' => '#FFFFFF'],
|
||||||
|
['name' => 'Gold', 'hex' => '#FFD700'],
|
||||||
|
['name' => 'Silver', 'hex' => '#C0C0C0'],
|
||||||
|
['name' => 'Cyan', 'hex' => '#00FFFF'],
|
||||||
|
['name' => 'Magenta', 'hex' => '#FF00FF'],
|
||||||
|
['name' => 'Lime', 'hex' => '#00FF00'],
|
||||||
|
['name' => 'Olive', 'hex' => '#808000'],
|
||||||
|
['name' => 'Teal', 'hex' => '#008080'],
|
||||||
|
['name' => 'Maroon', 'hex' => '#800000'],
|
||||||
|
['name' => 'Navy', 'hex' => '#000080'],
|
||||||
|
['name' => 'Aqua', 'hex' => '#00FFFF'],
|
||||||
|
['name' => 'Lavender', 'hex' => '#E6E6FA'],
|
||||||
|
['name' => 'Turquoise', 'hex' => '#40E0D0'],
|
||||||
|
['name' => 'Fuchsia', 'hex' => '#FF00FF'],
|
||||||
|
['name' => 'Indigo', 'hex' => '#4B0082'],
|
||||||
|
['name' => 'Crimson', 'hex' => '#DC143C'],
|
||||||
|
['name' => 'Plum', 'hex' => '#DDA0DD']
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($colors as $color) {
|
||||||
|
Color::create($color);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Database\Seeders;
|
||||||
|
|
||||||
|
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||||
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
|
use App\Models\Manufacturer;
|
||||||
|
|
||||||
|
class ManufacturerSeeder extends Seeder
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the database seeds.
|
||||||
|
*/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
// Seed Random Manufacturers
|
||||||
|
for ($i = 0; $i < 10; $i++) {
|
||||||
|
DB::table('manufacturers')->insert([
|
||||||
|
'name' => Str::random(10),
|
||||||
|
'description' => Str::random(40),
|
||||||
|
'website' => Str::random(10).'.com'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user