permissionRepository = $permissionRepository; $this->role = $role; } /** * Display a listing of the resource. */ public function index() { $data['title'] = 'Permission Lists'; $data['permissionLists'] = $this->permissionRepository->getPermissionListsArrangedByPrefix(); $data['roles'] = $this->role->pluck(); $data['editable'] = false; return view('crud.generated.permissions.index', $data); } /** * Show the form for creating a new resource. */ public function create() { $data['editable'] = false; $data['permissionLists'] = $this->permissionRepository->getPermissionListsArrangedByPrefix(); return view('user::role.create', $data); } /** * Store a newly created resource in storage. */ public function store(Request $request) { } /** * Display the specified resource. */ public function show(string $id) { } /** * Show the form for editing the specified resource. */ public function edit(Permission $permission) { $data['title'] = "Edit Role"; $data['editable'] = true; $data['role'] = $this->role->getRoleById($id); $data['permissionIDsArray'] = $data['role']?->permissions?->pluck('id')->toArray(); $data['permissionLists'] = $this->permissionRepository->getPermissionListsArrangedByPrefix(); return view('user::role.edit', $data); } /** * Update the specified resource in storage. */ public function update(Request $request, Permission $permission) { // } /** * Remove the specified resource from storage. */ public function destroy($id) { $permissionDelete = $this->permissionRepository->getPermissionById($id); $permissionDelete->delete(); return response()->json(['status' => true, 'message' => 'Permission has been deleted'] ); } public function generatePermissionFromRoutes() { try { $this->permissionRepository->generatePermissionFromRoutes(); toastr()->success('Permission generated successfully!'); } catch (\Throwable $th) { toastr()->error($th->getMessage()); } return to_route('permissions.index'); } }