create(); // Create roles $adminRole = Role::create(['name' => 'admin']); $privilegedRole = Role::create(['name' => 'privileged']); // Create permissions $editPermission = Permission::create(['name' => 'edit articles']); $deletePermission = Permission::create(['name' => 'delete articles']); // Assign permissions to roles $adminRole->givePermissionTo([$editPermission, $deletePermission]); $privilegedRole->givePermissionTo($editPermission); User::factory()->create([ 'name' => 'Test User', 'email' => 'test@example.com', 'password' => '12341234' ]); $user = User::find(1); // get a user $user->assignRole('admin'); } }