roleRepository = $roleRepository; } /** * Display a listing of the resource. */ public function index() { $data['roles'] = $this->roleRepository->findAll(); $data['editable'] = false; return view('user::role.index', $data); } /** * Show the form for creating a new resource. */ public function create() { $data['permissions'] = Permission::get(); $data['title'] = "Create Role"; return view('user::role.create', $data); } /** * Store a newly created resource in storage. */ public function store(Request $request) { $request->validate(['name' => 'required']); $role = $this->roleRepository->create($request->all()); $role->syncPermissions($request->permissions); toastr()->success('New role has been created!'); return redirect()->route('role.index'); } /** * Display the specified resource. */ public function show(string $id) { // } /** * Show the form for editing the specified resource. */ public function edit(Role $role) { $data['permissions'] = Permission::get(); $data['role'] = $role; $data['title'] = "Edit Role"; return view('user::role.edit', $data); } /** * Update the specified resource in storage. */ public function update(Request $request, Role $role) { $role->update(['name' => $request->name]); $role->syncPermissions($request->permissions); toastr()->success('Role has been updated!'); return redirect()->route('role.index'); } /** * Remove the specified resource from storage. */ public function destroy(Role $role) { $role->delete(); toastr()->success('Role has been deleted!'); } }