- Added new apis

This commit is contained in:
m.razaghi
2026-07-22 10:29:01 +03:30
parent 86c68951bb
commit a2799a8d1b
13 changed files with 334 additions and 15 deletions

View File

@@ -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');