'system_admin', 'guard_name' => 'web']); Permission::updateOrCreate(['name' => 'system_settings', 'guard_name' => 'web']); Permission::updateOrCreate(['name' => 'database_backup', 'guard_name' => 'web']); Permission::updateOrCreate(['name' => 'super_admin', 'guard_name' => 'web']); Permission::updateOrCreate(['name' => 'manager', 'guard_name' => 'web']); Permission::updateOrCreate(['name' => 'waiter', 'guard_name' => 'web']); Permission::updateOrCreate(['name' => 'employee', 'guard_name' => 'web']); Permission::updateOrCreate(['name' => 'chef', 'guard_name' => 'web']); Permission::updateOrCreate(['name' => 'delivery_man', 'guard_name' => 'web']); foreach ($this->superAdminPermissionList as $permission) { Permission::updateOrCreate(['name' => $permission, 'guard_name' => 'web']); } // SAAS Admin $saasAdminRole = Role::updateOrCreate(['name' => 'SAAS Admin', 'restaurant_id' => null, 'guard_name' => 'web']); // Create roles with guard names $systemAdminRole = Role::updateOrCreate(['name' => 'Super Admin', 'restaurant_id' => null, 'guard_name' => 'web']); // SuperOwner $restaurantOwnerRole = Role::updateOrCreate(['name' => 'Owner', 'restaurant_id' => null, 'guard_name' => 'web']); $restaurantMangerRole = Role::updateOrCreate(['name' => 'Manager', 'restaurant_id' => null, 'guard_name' => 'web']); $restaurantEmployeeRole = Role::updateOrCreate(['name' => 'Employee', 'restaurant_id' => null, 'guard_name' => 'web']); $restaurantWaiterRole = Role::updateOrCreate(['name' => 'Waiter', 'restaurant_id' => null, 'guard_name' => 'web']); $restaurantChefRole = Role::updateOrCreate(['name' => 'Chef', 'restaurant_id' => null, 'guard_name' => 'web']); $restaurantDeliveryManRole = Role::updateOrCreate(['name' => 'Delivery Man', 'restaurant_id' => null, 'guard_name' => 'web']); /* Assign Permissions to Roles */ $saasAdminRole->syncPermissions($this->saasAdminPermissionList); $systemAdminRole->syncPermissions($this->superAdminPermissionList); // Restaurant Owner $restaurantOwnerRole->syncPermissions($this->superAdminPermissionList); // Manager $restaurantMangerRole->syncPermissions($this->managerPermissions); // Employee $restaurantEmployeeRole->syncPermissions($this->employeePermissions); // Waiter $restaurantWaiterRole->syncPermissions($this->waiterPermissions); // Chef $restaurantChefRole->syncPermissions($this->chefPermissions); // DeliveryMan $restaurantDeliveryManRole->syncPermissions($this->deliveryManPermissions); /** Now Create User */ $this->createUser($saasAdminRole, 'SAAS Admin', 'saasadmin@gmail.com', '000000000002', '123456', null); $this->createUser($systemAdminRole, 'super-admin', 'admin@gmail.com', '00000000000', '123456', null); // Restaurant Owner $this->createUser($restaurantOwnerRole, 'Owner 1', 'restaurant1@gmail.com', '00000000001', '123456', 1); $this->createUser($restaurantOwnerRole, 'Owner 2', 'restaurant2@gmail.com', '00000000021', '123456', 2); // Restaurant Manger $this->createUser($restaurantMangerRole, 'Manager 1', 'manager1@gmail.com', '00000000002', '123456', 1); $this->createUser($restaurantMangerRole, 'Manager 2', 'manager2@gmail.com', '00000000022', '123456', 2); // Restaurant Employee $this->createUser($restaurantEmployeeRole, 'Employee 1', 'employee1@gmail.com', '00000000003', '123456', 1); $this->createUser($restaurantEmployeeRole, 'Employee 2', 'employee2@gmail.com', '00000000023', '123456', 2); // First 5 Restaurant 1 $this->createUser($restaurantWaiterRole, 'Waiter 1', 'waiter1@gmail.com', '00000000011', '123456', 1); $this->createUser($restaurantWaiterRole, 'Waiter 2', 'waiter2@gmail.com', '00000000012', '123456', 1); $this->createUser($restaurantWaiterRole, 'Waiter 3', 'waiter3@gmail.com', '00000000013', '123456', 1); $this->createUser($restaurantWaiterRole, 'Waiter 4', 'waiter4@gmail.com', '00000000014', '123456', 1); $this->createUser($restaurantWaiterRole, 'Waiter 5', 'waiter5@gmail.com', '00000000015', '123456', 1); // First 5 Restaurant 2 $this->createUser($restaurantWaiterRole, 'Waiter 6', 'waiter6@gmail.com', '00000000031', '123456', 2); $this->createUser($restaurantWaiterRole, 'Waiter 7', 'waiter7@gmail.com', '00000000032', '123456', 2); $this->createUser($restaurantWaiterRole, 'Waiter 8', 'waiter8@gmail.com', '00000000033', '123456', 2); $this->createUser($restaurantWaiterRole, 'Waiter 9', 'waiter9@gmail.com', '00000000034', '123456', 2); $this->createUser($restaurantWaiterRole, 'Waiter 10', 'waiter10@gmail.com', '00000000035', '123456', 2); // Restaurant Chef $this->createUser($restaurantChefRole, 'Chef 1', 'chef1@gmail.com', '00000000034', '123456', 1); $this->createUser($restaurantChefRole, 'Chef 2', 'chef1@gmail.com', '00000000034', '123456', 1); $this->createUser($restaurantChefRole, 'Chef 1', 'chef2@gmail.com', '000000000044', '123456', 2); $this->createUser($restaurantChefRole, 'Chef 2', 'chef2@gmail.com', '000000000044', '123456', 2); // Restaurant DeliveryMan $this->createUser($restaurantDeliveryManRole, 'DeliveryMan 1', 'deliveryman1@gmail.com', '00000000005', '123456', 1); $this->createUser($restaurantDeliveryManRole, 'DeliveryMan 2', 'deliveryman2@gmail.com', '000000000025', '123456', 2); } public function createUser(Role $role, string $name, string $email, string $phone, string $password, ?int $restaurantId = null) { $user = User::factory([ 'first_name' => $name, 'email' => $email, 'email_verified_at' => now(), 'password' => Hash::make($password), 'phone' => $phone, 'user_type' => $role->name, 'role_id' => $role->id, 'remember_token' => Str::random(10), 'platform' => 'WEB', 'address' => 'Dhaka, Bangladesh', 'status' => 1, 'created_by' => 1, 'restaurant_id' => $restaurantId, 'created_at' => now(), 'updated_at' => now(), ])->create(); /* Get all the permission and assign admin role */ $user->assignRole([$role->id]); } }