Fixed major bugs
This commit is contained in:
@@ -59,9 +59,6 @@ class JudicialPrecedentApiController extends Controller
|
||||
return $this->success($responseData, 'Success', 'Judicial Precedents Fetched');
|
||||
}
|
||||
|
||||
/**
|
||||
* Search Judicial Precedents by Keyword
|
||||
*/
|
||||
public function search(Request $request)
|
||||
{
|
||||
$request->validate([
|
||||
@@ -141,20 +138,25 @@ class JudicialPrecedentApiController extends Controller
|
||||
return $this->success($results, 'Success', 'Pager Window Details');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to format payload uniformly
|
||||
*/
|
||||
private function isLockedForCurrentUser($item): bool
|
||||
{
|
||||
return ! auth()->user()->isSubscriber() && (bool) ($item->is_locked ?? false);
|
||||
}
|
||||
|
||||
private function formatItem($item)
|
||||
{
|
||||
$isLocked = $this->isLockedForCurrentUser($item);
|
||||
|
||||
return [
|
||||
'id' => $item->id,
|
||||
'ruling_number' => $item->ruling_number,
|
||||
'ruling_date' => $item->ruling_date,
|
||||
'subject' => $item->subject,
|
||||
'full_text' => $item->full_text,
|
||||
'full_text' => $isLocked ? null : $item->full_text,
|
||||
'issuing_authority' => $item->issuing_authority,
|
||||
'category_id' => $item->category_id,
|
||||
'category_name' => optional($item->category)->name,
|
||||
'is_locked' => $isLocked,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user