- Added new apis
This commit is contained in:
@@ -172,21 +172,29 @@ class LegalOpinionApiController extends Controller
|
||||
}
|
||||
})->orderBy('opinion_date', 'asc')->orderBy('id', 'asc')->first();
|
||||
|
||||
// Apply format and add Notes
|
||||
$formatWithNote = function($item) {
|
||||
// Apply format and add Notes & Highlights
|
||||
$formatWithNoteAndHighlight = function($item) {
|
||||
if (!$item) return null;
|
||||
$formatted = $this->formatItem($item);
|
||||
|
||||
$formatted['note'] = \App\Models\LegalOpinionNote::select('id', 'note', 'color_code', 'created_at')
|
||||
->where('user_id', auth()->user()->id)
|
||||
->where('user_id', auth()->id())
|
||||
->where('legal_opinion_id', $item->id)
|
||||
->get();
|
||||
|
||||
// NEW: Fetch Highlights
|
||||
$formatted['highlight'] = \App\Models\LegalOpinionHighlight::select('id', 'start_index', 'end_index', 'selected_text', 'color_code')
|
||||
->where('user_id', auth()->id())
|
||||
->where('legal_opinion_id', $item->id)
|
||||
->get();
|
||||
|
||||
return $formatted;
|
||||
};
|
||||
|
||||
$results = array_values(array_filter([
|
||||
$previousItem ? $formatWithNote($previousItem) : null,
|
||||
$formatWithNote($current),
|
||||
$nextItem ? $formatWithNote($nextItem) : null
|
||||
$previousItem ? $formatWithNoteAndHighlight($previousItem) : null,
|
||||
$formatWithNoteAndHighlight($current),
|
||||
$nextItem ? $formatWithNoteAndHighlight($nextItem) : null
|
||||
]));
|
||||
|
||||
return $this->success($results, 'Success', 'Pager Window Details');
|
||||
|
||||
Reference in New Issue
Block a user