pai-sklep/database/seeders/DatabaseSeeder.php
2021-12-08 23:39:53 +01:00

35 lines
875 B
PHP

<?php
namespace Database\Seeders;
use App\Models\Category;
use App\Models\Image;
use App\Models\User;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run()
{
User::factory(10)->create();
$creds = [
'email' => config('admin.email'),
'name' => config('admin.username'),
'password' => config('admin.password'),
];
$creds["password"] = Hash::make($creds["password"]);
$user = User::create($creds);
$user->admin = true;
$user->save();
$categories = Category::factory()->count(4)->create();
\App\Models\Product::factory(10)->has(Image::factory()->count(3))->hasAttached($categories)->create();
}
}