Files
law-api/app/Http/Controllers/Admin/BylawCodificationLinkController.php

57 lines
2.5 KiB
PHP

<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Models\BylawCodificationLink;
use Illuminate\Http\Request;
class BylawCodificationLinkController extends Controller
{
public function index()
{
$items = BylawCodificationLink::latest('created_at')->paginate(15);
return view('admin.bylaw-codification-link.index', compact('items'));
}
public function create()
{
return view('admin.bylaw-codification-link.create');
}
public function store(Request $request)
{
$data = $request->validate(['source_entity_type' => 'required|in:bylaw_node,bylaw_doc,law_doc,court_verdict,advisory_opinion', 'source_entity_id' => 'required|integer', 'target_entity_type' => 'required|in:bylaw_node,bylaw_doc,law_doc,court_verdict,advisory_opinion', 'target_entity_id' => 'required|integer', 'link_type' => 'required|in:repeals_explicitly,repeals_implicitly,annuls_entirely,annuls_partially,amends,adds_to,interprets,is_executive_bylaw_of', 'effective_date' => 'nullable|date', 'justification' => 'nullable|string']);
$data['created_at'] = now();
BylawCodificationLink::create($data);
return redirect(route('bylaw-codification-link.index'));
}
public function edit(BylawCodificationLink $bylawCodificationLink)
{
return view('admin.bylaw-codification-link.update', compact('bylawCodificationLink'));
}
public function show(BylawCodificationLink $bylawCodificationLink)
{
return redirect(route('bylaw-codification-link.edit', $bylawCodificationLink));
}
public function update(Request $request, BylawCodificationLink $bylawCodificationLink)
{
$data = $request->validate(['source_entity_type' => 'required|in:bylaw_node,bylaw_doc,law_doc,court_verdict,advisory_opinion', 'source_entity_id' => 'required|integer', 'target_entity_type' => 'required|in:bylaw_node,bylaw_doc,law_doc,court_verdict,advisory_opinion', 'target_entity_id' => 'required|integer', 'link_type' => 'required|in:repeals_explicitly,repeals_implicitly,annuls_entirely,annuls_partially,amends,adds_to,interprets,is_executive_bylaw_of', 'effective_date' => 'nullable|date', 'justification' => 'nullable|string']);
$bylawCodificationLink->update($data);
return redirect(route('bylaw-codification-link.edit', $bylawCodificationLink));
}
public function destroy(BylawCodificationLink $bylawCodificationLink)
{
$bylawCodificationLink->delete();
return redirect(route('bylaw-codification-link.index'));
}
}