filled('q')) { $query->where('name', 'like', "%{$request->q}%"); } $items = $query->latest()->paginate(15)->withQueryString(); return view('admin.bylaw-legal-authority.index', compact('items')); } public function create() { return view('admin.bylaw-legal-authority.create'); } public function store(Request $request) { $data = $request->validate(['name' => 'required|unique:bylaw_legal_authorities,name', 'authority_type' => 'required|in:executive,judicial,legislative,administrative,other', 'description' => 'nullable|string']); BylawLegalAuthority::create($data); return redirect(route('bylaw-legal-authority.index')); } public function edit(BylawLegalAuthority $bylawLegalAuthority) { return view('admin.bylaw-legal-authority.update', compact('bylawLegalAuthority')); } public function show(BylawLegalAuthority $bylawLegalAuthority) { return redirect(route('bylaw-legal-authority.edit', $bylawLegalAuthority)); } public function update(Request $request, BylawLegalAuthority $bylawLegalAuthority) { $data = $request->validate(['name' => 'required|unique:bylaw_legal_authorities,name,'.$bylawLegalAuthority->id, 'authority_type' => 'required|in:executive,judicial,legislative,administrative,other', 'description' => 'nullable|string']); $bylawLegalAuthority->update($data); return redirect(route('bylaw-legal-authority.edit', $bylawLegalAuthority)); } public function destroy(BylawLegalAuthority $bylawLegalAuthority) { $bylawLegalAuthority->delete(); return redirect(route('bylaw-legal-authority.index')); } }