31 lines
859 B
PHP
31 lines
859 B
PHP
{{-- @api-readonly --}}
|
|
<?php
|
|
use App\Models\InspectionHistory;
|
|
use App\Models\User;
|
|
|
|
$records = InspectionHistory::where('table_name', 'Other')
|
|
->orderBy('id', 'DESC')
|
|
->get();
|
|
|
|
$users = User::all()->pluck('name', 'id')->toArray();
|
|
|
|
$data = $records->map(function($record) use ($users) {
|
|
return [
|
|
'id' => $record->id,
|
|
'user_name' => $users[$record->user_id] ?? 'Unknown',
|
|
'created_at' => $record->created_at->format('d.MM.Y H:i'), // DevExtreme format compatible or ISO
|
|
'date' => $record->created_at->toIso8601String(),
|
|
'ip_address' => $record->ip_address,
|
|
'comment' => $record->comment,
|
|
'file_path' => $record->file_path,
|
|
'file_name' => $record->file_name,
|
|
];
|
|
});
|
|
|
|
echo json_encode([
|
|
'status' => 'success',
|
|
'data' => $data,
|
|
'totalCount' => $records->count()
|
|
]);
|
|
?>
|