<?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',
            'gender_id' => 1,
            'dept_id' => 1,
            'phone' => '0911405218',
            'email_verified_at' =>'2023-08-05 17:57:38',
            'roles_name' => ["owner"],
            ]);
            $role = Role::create(['name' => 'owner']);
   
            $permissions = Permission::pluck('id','id')->all();
      
            $role->syncPermissions($permissions);
       
            $user->assignRole([$role->id]);
    }
}
