latest()->paginate(15); return view('admin.bylaw-node.index', compact('items')); } public function create() { return view('admin.bylaw-node.create', ['documents' => BylawDocument::all(), 'types' => BylawNodeType::all(), 'parents' => BylawNode::all()]); } public function store(Request $request) { $data = $request->validate(['document_id' => 'required|exists:bylaw_documents,id', 'parent_id' => 'nullable|exists:bylaw_nodes,id', 'node_type_id' => 'required|exists:bylaw_node_types,id', 'node_identifier' => 'nullable|string|max:50', 'title' => 'nullable|string|max:500', 'node_content' => 'nullable|string', 'sort_order' => 'nullable|integer', 'valid_from' => 'nullable|date', 'valid_to' => 'nullable|date', 'node_status' => 'required|in:valid,repealed,annulled,amended,suspended']); BylawNode::create($data); return redirect(route('bylaw-node.index')); } public function edit(BylawNode $bylawNode) { return view('admin.bylaw-node.update', ['bylawNode' => $bylawNode, 'documents' => BylawDocument::all(), 'types' => BylawNodeType::all(), 'parents' => BylawNode::where('id', '!=', $bylawNode->id)->get()]); } public function show(BylawNode $bylawNode) { return redirect(route('bylaw-node.edit', $bylawNode)); } public function update(Request $request, BylawNode $bylawNode) { $data = $request->validate(['document_id' => 'required|exists:bylaw_documents,id', 'parent_id' => 'nullable|exists:bylaw_nodes,id', 'node_type_id' => 'required|exists:bylaw_node_types,id', 'node_identifier' => 'nullable|string|max:50', 'title' => 'nullable|string|max:500', 'node_content' => 'nullable|string', 'sort_order' => 'nullable|integer', 'valid_from' => 'nullable|date', 'valid_to' => 'nullable|date', 'node_status' => 'required|in:valid,repealed,annulled,amended,suspended']); $bylawNode->update($data); return redirect(route('bylaw-node.edit', $bylawNode)); } public function destroy(BylawNode $bylawNode) { $bylawNode->delete(); return redirect(route('bylaw-node.index')); } }