Fixed major bugs
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user