<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\User;
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;

class UsersTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
       
        $user = User::create([
            'first_name' => 'Mustafa Adel', 
            'email' => 'mostafa@gmail.com',
            'password' => bcrypt('newday77'),
            'user_type' => 'admin',
            'roles_name' => 'owner',
            'phone' => '0911405218',
            'email_verified_at' =>'2023-08-05 17:57:38',
          
            ]);

            $role = Role::create(['name' => 'owner']);
            $permissions = Permission::pluck('id','id')->all();
            $role->syncPermissions($permissions);$user->assignRole([$role->id]);

    }
}
