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'])