feat: add bylaw management features including documents, legal authorities, subject categories, and nodes

This commit is contained in:
2026-06-26 13:49:50 +03:30
parent 2e26bd229b
commit 9cf6957675
113 changed files with 1112 additions and 358 deletions

View File

@@ -0,0 +1,69 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\BylawDocument;
use App\Models\BylawLegalAuthority;
use App\Models\BylawSubjectCategory;
use Illuminate\Http\Request;
class BylawDocumentController extends Controller
{
public function index(Request $request)
{
$query = BylawDocument::with(['category', 'approvalAuthority', 'promulgationAuthority']);
if ($request->filled('q')) {
$query->where('title', 'like', "%{$request->q}%");
}
$items = $query->latest()->paginate(15)->withQueryString();
return view('admin.bylaw-document.index', compact('items'));
}
public function create()
{
$categories = BylawSubjectCategory::all();
$authorities = BylawLegalAuthority::all();
return view('admin.bylaw-document.create', compact('categories', 'authorities'));
}
public function store(Request $request)
{
$data = $request->validate(['title' => 'required|string|max:1000', 'category_id' => 'nullable|exists:bylaw_subject_categories,id', 'approval_authority_id' => 'nullable|exists:bylaw_legal_authorities,id', 'approval_date' => 'nullable|date', 'promulgation_authority_id' => 'nullable|exists:bylaw_legal_authorities,id', 'promulgation_date' => 'nullable|date', 'promulgation_number' => 'nullable|string|max:100', 'official_gazette_number' => 'nullable|string|max:100', 'official_gazette_date' => 'nullable|date', 'execution_date' => 'nullable|date', 'bylaw_type' => 'required|in:executive,delegated,independent', 'global_status' => 'required|in:valid,explicitly_repealed,implicitly_repealed,annulled,expired,draft', 'pdf_file_path' => 'nullable|string|max:500', 'is_published' => 'nullable|boolean', 'description' => 'nullable|string']);
$data['is_published'] = $request->boolean('is_published');
BylawDocument::create($data);
return redirect(route('bylaw-document.index'));
}
public function edit(BylawDocument $bylawDocument)
{
$categories = BylawSubjectCategory::all();
$authorities = BylawLegalAuthority::all();
return view('admin.bylaw-document.update', compact('bylawDocument', 'categories', 'authorities'));
}
public function show(BylawDocument $bylawDocument)
{
return redirect(route('bylaw-document.edit', $bylawDocument));
}
public function update(Request $request, BylawDocument $bylawDocument)
{
$data = $request->validate(['title' => 'required|string|max:1000', 'category_id' => 'nullable|exists:bylaw_subject_categories,id', 'approval_authority_id' => 'nullable|exists:bylaw_legal_authorities,id', 'approval_date' => 'nullable|date', 'promulgation_authority_id' => 'nullable|exists:bylaw_legal_authorities,id', 'promulgation_date' => 'nullable|date', 'promulgation_number' => 'nullable|string|max:100', 'official_gazette_number' => 'nullable|string|max:100', 'official_gazette_date' => 'nullable|date', 'execution_date' => 'nullable|date', 'bylaw_type' => 'required|in:executive,delegated,independent', 'global_status' => 'required|in:valid,explicitly_repealed,implicitly_repealed,annulled,expired,draft', 'pdf_file_path' => 'nullable|string|max:500', 'is_published' => 'nullable|boolean', 'description' => 'nullable|string']);
$data['is_published'] = $request->boolean('is_published');
$bylawDocument->update($data);
return redirect(route('bylaw-document.edit', $bylawDocument));
}
public function destroy(BylawDocument $bylawDocument)
{
$bylawDocument->delete();
return redirect(route('bylaw-document.index'));
}
}