debuge refer list

This commit is contained in:
2025-02-26 17:09:44 +03:30
parent 227faa1eee
commit 3fb6c61835

View File

@@ -172,20 +172,22 @@ class RoadObservationController extends Controller
public function referList(RoadObserved $roadObserved): JsonResponse
{
$referList = [];
$data = RoadObservationHistory::query()
->where('road_observation_histories.id', $roadObserved->id)
->where('action', '=', 'refer')->get();
->where('action', '=', 'refer')->get([
'created_at', 'description', 'from_edareh', 'to_edareh',
'from_province', 'to_province', 'user_id'
]);
foreach ($data as $key => $value) {
$referList[$key]['from_edareh'] = EdarateShahri::query()->find($value->from_edareh)->name_fa;
$referList[$key]['to_edareh'] = EdarateShahri::query()->find($value->to_edareh)->name_fa;
$referList[$key]['from_province'] = Province::query()->find($value->from_province)->name_fa;
$referList[$key]['to_province'] = Province::query()->find($value->to_province)->name_fa;
$data[$key]->from_edareh = EdarateShahri::query()->find($value->from_edareh)->name_fa;
$data[$key]->to_edareh = EdarateShahri::query()->find($value->to_edareh)->name_fa;
$data[$key]->from_province = EdarateShahri::query()->find($value->from_province)->name_fa;
$data[$key]->to_province = EdarateShahri::query()->find($value->to_province)->name_fa;
$user = User::query()->find($value->user_id);
$referList[$key]['user'] = $user->first_name . ' ' . $user->last_name;
$data[$key]->user = $user->first_name . ' ' . $user->last_name;
}
return $this->successResponse($referList);
return $this->successResponse($data);
}
public function restore(RestoreRequest $request, RoadObserved $roadObserved): JsonResponse