pai-sklep/database/seeders/DatabaseSeeder.php

36 lines
875 B
PHP
Raw Permalink Normal View History

2021-09-05 02:22:17 +02:00
<?php
namespace Database\Seeders;
2021-12-08 23:39:53 +01:00
use App\Models\Category;
2021-11-14 20:44:10 +01:00
use App\Models\Image;
2021-11-20 22:12:35 +01:00
use App\Models\User;
2021-09-05 02:22:17 +02:00
use Illuminate\Database\Seeder;
2021-11-20 22:12:35 +01:00
use Illuminate\Support\Facades\Hash;
2021-09-05 02:22:17 +02:00
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
2021-11-20 22:12:35 +01:00
User::factory(10)->create();
2021-12-08 23:39:53 +01:00
2021-11-20 22:12:35 +01:00
$creds = [
'email' => config('admin.email'),
'name' => config('admin.username'),
2021-11-24 11:34:46 +01:00
'password' => config('admin.password'),
2021-11-20 22:12:35 +01:00
];
$creds["password"] = Hash::make($creds["password"]);
$user = User::create($creds);
$user->admin = true;
$user->save();
2021-12-08 23:39:53 +01:00
$categories = Category::factory()->count(4)->create();
\App\Models\Product::factory(10)->has(Image::factory()->count(3))->hasAttached($categories)->create();
2021-09-05 02:22:17 +02:00
}
}