diff --git a/backend/app/Http/Controllers/Api/MeetingsController.php b/backend/app/Http/Controllers/Api/MeetingsController.php index 5e997adc..c0857b04 100644 --- a/backend/app/Http/Controllers/Api/MeetingsController.php +++ b/backend/app/Http/Controllers/Api/MeetingsController.php @@ -151,8 +151,10 @@ class MeetingsController extends Controller { if (null === ($l->meeting_images = MeetingImage::select($meeting_images_select)->where('meeting_id', (int)$l->id)->get())) { $l->meeting_images = []; } - if (null === ($l->fathers = Father::select($father_select)->where('id', (int)$l->father_id)->first())) { - $l->fathers = new \stdClass(); + if (null !== ($fr = FatherRelation::select('father_id')->where('child_id', (int)$r->child_id)->first())) { + if (null === ($l->father = Father::select($father_select)->where('id', (int)$fr->father_id)->first())) { + $l->father = new \stdClass(); + } } if (null === ($l->meeting_approvals = MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', (int)$l->id)->orderBy('updated_at', 'desc')->get())) { $l->meeting_approvals = []; @@ -189,8 +191,10 @@ class MeetingsController extends Controller { if (null === ($l->meeting_images = MeetingImage::select($meeting_images_select)->where('meeting_id', (int)$l->id)->get())) { $l->meeting_images = []; } - if (null === ($l->fathers = Father::select($father_select)->where('id', (int)$l->father_id)->first())) { - $l->fathers = new \stdClass(); + if (null !== ($fr = FatherRelation::select('father_id')->where('child_id', (int)$r->child_id)->first())) { + if (null === ($l->father = Father::select($father_select)->where('id', (int)$fr->father_id)->first())) { + $l->father = new \stdClass(); + } } if (null === ($l->meeting_approvals = MeetingApprovals::select($meeting_approvals_select)->whereNull('approval_at')->where('meeting_id', (int)$l->id)->orderBy('approval_at', 'asc')->get())) { $l->meeting_approvals = []; @@ -351,8 +355,10 @@ class MeetingsController extends Controller { } foreach ($list as $i => $l) { - if (null === ($l->father = Father::select($father_select)->where('id', (int)$l->father_id)->first())) { - $l->father = []; + if (null !== ($fr = FatherRelation::select('father_id')->where('child_id', (int)$r->child_id)->first())) { + if (null === ($l->father = Father::select($father_select)->where('id', (int)$fr->father_id)->first())) { + $l->father = new \stdClass(); + } } if (null === ($l->approval = MeetingApprovals::select($meeting_approvals_select)->where('child_id', (int)$r->child_id)->whereNotNull('approval_at')->get())) { $l->approval = []; @@ -379,8 +385,10 @@ class MeetingsController extends Controller { } foreach ($list as $i => $l) { - if (null === ($l->father = Father::select($father_select)->where('id', (int)$l->father_id)->first())) { - $l->father = []; + if (null !== ($fr = FatherRelation::select('father_id')->where('child_id', (int)$r->child_id)->first())) { + if (null === ($l->father = Father::select($father_select)->where('id', (int)$fr->father_id)->first())) { + $l->father = new \stdClass(); + } } if (null === ($l->approval = MeetingApprovals::select($meeting_approvals_select)->where('child_id', (int)$r->child_id)->whereNull('approval_at')->get())) { $l->approval = [];