/** * Test effective menu and permission. */ public function testEffectiveItems() { Artisan::call('migrate'); $user = User::create(['name' => 'Ifan Iqbal', 'email' => '*****@*****.**', 'password' => 'secret']); $group = Group::create(['name' => 'admin']); for ($i = 0; $i < 2; $i++) { $menu = Menu::create(['parent_id' => 0, 'name' => 'Menu ' . $i + 1, 'order' => $i + 1, 'enabled' => 1]); Menu::create(['parent_id' => $menu->id, 'name' => 'Child 1', 'order' => 1, 'enabled' => 1]); Menu::create(['parent_id' => $menu->id, 'name' => 'Child 2', 'order' => 2, 'enabled' => 1]); } for ($i = 0; $i < 4; $i++) { Permission::create(['route' => 'permission_' . $i + 1, 'enabled' => 1]); } $menus = Menu::get(); $permissions = Permission::get(); $user->groups()->attach($group); $group->menus()->sync($menus); $group->permissions()->sync($permissions); Auth::loginUsingId($user->id); $this->assertEquals(6, Sysguard::getEffectiveMenu()->count()); $this->assertEquals(4, Sysguard::getEffectivePermission()->count()); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $user = User::findOrFail($id); $user->delete(); return redirect()->route('user.index'); }