feat(Category): add category
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Art;
|
||||
use App\Models\JudicialPrecedent;
|
||||
use App\Models\JudicialPrecedentCategory;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class JudicialPrecedentController extends Controller
|
||||
@@ -31,7 +32,8 @@ class JudicialPrecedentController extends Controller
|
||||
public function create()
|
||||
{
|
||||
$arts = Art::all();
|
||||
return view('admin.judicial-precedent.create', compact('arts'));
|
||||
$categories = JudicialPrecedentCategory::all();
|
||||
return view('admin.judicial-precedent.create', compact('arts', 'categories'));
|
||||
}
|
||||
|
||||
public function store(Request $request)
|
||||
@@ -42,6 +44,7 @@ class JudicialPrecedentController extends Controller
|
||||
'subject' => 'required|string',
|
||||
'full_text' => 'required|string',
|
||||
'issuing_authority' => 'nullable|string',
|
||||
'category_id' => 'nullable|exists:judicial_precedent_categories,id',
|
||||
'art_ids' => 'nullable|array',
|
||||
'art_ids.*' => 'exists:arts,id'
|
||||
]);
|
||||
@@ -51,7 +54,8 @@ class JudicialPrecedentController extends Controller
|
||||
'ruling_date' => $validated['ruling_date'],
|
||||
'subject' => $validated['subject'],
|
||||
'full_text' => $validated['full_text'],
|
||||
'issuing_authority' => $validated['issuing_authority'] ?? 'هیأت عمومی دیوان عالی کشور'
|
||||
'issuing_authority' => $validated['issuing_authority'] ?? 'هیأت عمومی دیوان عالی کشور',
|
||||
'category_id' => $validated['category_id']
|
||||
]);
|
||||
|
||||
if (!empty($validated['art_ids'])) {
|
||||
@@ -64,9 +68,10 @@ class JudicialPrecedentController extends Controller
|
||||
public function edit(JudicialPrecedent $judicialPrecedent)
|
||||
{
|
||||
$arts = Art::all();
|
||||
$categories = JudicialPrecedentCategory::all();
|
||||
$selectedArtIds = $judicialPrecedent->arts->pluck('id')->toArray();
|
||||
|
||||
return view('admin.judicial-precedent.update', compact('judicialPrecedent', 'arts', 'selectedArtIds'));
|
||||
return view('admin.judicial-precedent.update', compact('judicialPrecedent', 'arts', 'categories', 'selectedArtIds'));
|
||||
}
|
||||
|
||||
public function update(Request $request, JudicialPrecedent $judicialPrecedent)
|
||||
@@ -77,6 +82,7 @@ class JudicialPrecedentController extends Controller
|
||||
'subject' => 'required|string',
|
||||
'full_text' => 'required|string',
|
||||
'issuing_authority' => 'nullable|string',
|
||||
'category_id' => 'nullable|exists:judicial_precedent_categories,id',
|
||||
'art_ids' => 'nullable|array',
|
||||
'art_ids.*' => 'exists:arts,id'
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user