Fixed major bugs

This commit is contained in:
m.razaghi
2026-07-09 19:11:39 +03:30
parent 71dc7da8a4
commit 71a6f683a7
4 changed files with 90 additions and 8 deletions

View File

@@ -123,6 +123,34 @@ class BylawApiController extends Controller
return $this->success($responseData, 'Success', 'Search Results Fetched');
}
public function fast_search(Request $request)
{
$searchTerm = $request->input('search');
$query = BylawDocument::with(['category', 'approvalAuthority', 'promulgationAuthority'])
->where('is_published', true);
if (!empty($searchTerm)) {
$query->where(function ($q) use ($searchTerm) {
$q->where('title', 'LIKE', "%{$searchTerm}%")
->orWhere('description', 'LIKE', "%{$searchTerm}%")
->orWhere('promulgation_number', 'LIKE', "%{$searchTerm}%")
->orWhere('official_gazette_number', 'LIKE', "%{$searchTerm}%");
});
}
$count = $query->count();
// Limit to 5 results for fast search dropdown
$items = $query->orderBy('approval_date', 'desc')->take(5)->get()->map(function ($item) {
return $this->formatBylaw($item);
});
return $this->success([
'items' => $items,
'count' => $count
], 'Success', 'Fast Search Results');
}
public function pager($id)
{
$current = BylawDocument::with(['category', 'approvalAuthority', 'promulgationAuthority'])

View File

@@ -96,6 +96,31 @@ class JudicialPrecedentApiController extends Controller
return $this->success($responseData, 'Success', 'Search Results Fetched');
}
public function fast_search(Request $request)
{
$searchTerm = $request->input('search');
$query = JudicialPrecedent::query();
if (!empty($searchTerm)) {
$query->where(function ($q) use ($searchTerm) {
$q->where('ruling_number', 'LIKE', "%{$searchTerm}%")
->orWhere('subject', 'LIKE', "%{$searchTerm}%")
->orWhere('full_text', 'LIKE', "%{$searchTerm}%");
});
}
$count = $query->count();
// Limit to 5 results for fast search dropdown
$items = $query->orderBy('ruling_date', 'desc')->take(5)->get()->map(function ($item) {
return $this->formatItem($item);
});
return $this->success([
'items' => $items,
'count' => $count
], 'Success', 'Fast Search Results');
}
public function pager($id)
{
$current = JudicialPrecedent::find($id);

View File

@@ -97,6 +97,32 @@ class LegalOpinionApiController extends Controller
return $this->success($responseData, 'Success', 'Search Results Fetched');
}
public function fast_search(Request $request)
{
$searchTerm = $request->input('search');
$query = LegalOpinion::query();
if ($request->filled('search')) {
$query->where(function ($q) use ($searchTerm) {
$q->where('opinion_number', 'LIKE', "%{$searchTerm}%")
->orWhere('subject', 'LIKE', "%{$searchTerm}%")
->orWhere('full_text', 'LIKE', "%{$searchTerm}%")
->orWhere('issuing_authority', 'LIKE', "%{$searchTerm}%");
});
}
$count = $query->count();
// Limit to 5 results for fast search dropdown
$items = $query->orderBy('opinion_date', 'desc')->take(5)->get()->map(function ($item) {
return $this->formatItem($item);
});
return $this->success([
'items' => $items,
'count' => $count
], 'Success', 'Fast Search Results');
}
public function pager($id)
{
$current = LegalOpinion::find($id);