authorize('view', 'branches'); $branches = Branch::latest('id')->paginate(20); return view('dashboard.branches.index', compact('branches')); } public function store(Request $request) { if ($request->isMethod('get')) { $this->authorize('create', 'branches'); return view('dashboard.branches.create'); } $this->dispatchSync(new Store($request)); $this->success(trans('admin.messages.created')); return redirect()->route('dashboard.branches'); } public function show(Branch $branch) { $this->authorize('view', 'branches'); return view('dashboard.branches.preview', compact('branch')); } public function update(Request $request, Branch $branch) { if ($request->isMethod('get')) { $this->authorize('update', 'branches'); return view('dashboard.branches.edit', compact('branch')); } $this->dispatchSync(new Update($request, $branch)); $this->success(trans('admin.messages.created')); return redirect()->route('dashboard.branches'); } public function destroy(Branch $branch) { $this->authorize('delete', 'branches'); $branch->delete(); $this->success(trans('admin.messages.deleted')); return redirect()->back(); } }