feat: add bylaw management features including documents, legal authorities, subject categories, and nodes
This commit is contained in:
59
app/Http/Controllers/Admin/BylawLegalAuthorityController.php
Normal file
59
app/Http/Controllers/Admin/BylawLegalAuthorityController.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\BylawLegalAuthority;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BylawLegalAuthorityController extends Controller
|
||||
{
|
||||
public function index(Request $request)
|
||||
{
|
||||
$query = BylawLegalAuthority::query();
|
||||
if ($request->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'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user