diff --git a/backend/app/Http/Controllers/Api/ChildrenController.php b/backend/app/Http/Controllers/Api/ChildrenController.php index 41b82ed2..408b01c6 100644 --- a/backend/app/Http/Controllers/Api/ChildrenController.php +++ b/backend/app/Http/Controllers/Api/ChildrenController.php @@ -240,7 +240,9 @@ KIKI承知システムを使って「聞いてない!」「言ってない! } public function list () { - if (null === ($result = Child::orderBy('created_at', 'desc')->get())) { + $child_select = ['first_name', 'last_name', 'tel']; + + if (null === ($result = Child::select($child_select)->orderBy('created_at', 'desc')->get())) { // 親一覧の取得に失敗 return ['status_code' => 400]; } @@ -254,7 +256,7 @@ KIKI承知システムを使って「聞いてない!」「言ってない! return ['status_code' => 400]; } $result = []; - $child_select = ['id', 'first_name', 'last_name', 'tel']; + $child_select = ['id', 'image', 'first_name', 'last_name', 'company', 'tel']; if (null === ($list = FatherRelation::select('child_id')->where('father_id', (int)$r->father_id)->orderBy('created_at', 'desc')->get())) { return ['status_code' => 400]; diff --git a/backend/app/Http/Controllers/Api/MeetingsController.php b/backend/app/Http/Controllers/Api/MeetingsController.php index 7ed21714..dbd8b516 100644 --- a/backend/app/Http/Controllers/Api/MeetingsController.php +++ b/backend/app/Http/Controllers/Api/MeetingsController.php @@ -237,15 +237,21 @@ class MeetingsController extends Controller { } foreach ($list as $i => $l) { - if (null !== ($l->approvals = MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', (int)$l->id)->get())) { - foreach ($l->approvals as $ii => $ll) { - if (null === ($ll->child = Child::select($child_select)->where('id', (int)$ll->child_id)->first())) { - $ll->child = new \stdClass(); - } + if (null === ($l->approvals = MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', (int)$l->id)->get())) { + continue; + } - if (!in_array($l, $result)) { - $result[] = $l; - } + if (count($l->approvals->toArray()) != MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$l->id)->count()) { + continue; + } + + foreach ($l->approvals as $ii => $ll) { + if (null === ($ll->child = Child::select($child_select)->where('id', (int)$ll->child_id)->first())) { + $ll->child = new \stdClass(); + } + + if (!in_array($l, $result)) { + $result[] = $l; } } } @@ -269,15 +275,21 @@ class MeetingsController extends Controller { } foreach ($list as $i => $l) { - if (null !== ($l->approvals = MeetingApprovals::select($meeting_approvals_select)->whereNull('approval_at')->where('meeting_id', (int)$l->id)->get())) { - foreach ($l->approvals as $ii => $ll) { - if (null === ($ll->child = Child::select($child_select)->where('id', (int)$ll->child_id)->first())) { - $ll->child = new \stdClass(); - } + if (null === ($l->approvals = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$l->id)->get())) { + continue; + } - if (!in_array($l, $result)) { - $result[] = $l; - } + if (count($l->approvals) == MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', (int)$l->id)->count()) { + continue; + } + + foreach ($l->approvals as $ii => $ll) { + if (null === ($ll->child = Child::select($child_select)->where('id', (int)$ll->child_id)->first())) { + $ll->child = new \stdClass(); + } + + if (!in_array($l, $result)) { + $result[] = $l; } } } @@ -297,21 +309,27 @@ class MeetingsController extends Controller { // 取得に成功 if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)$r->father_id)->where('is_favorite', 1)->get())) { - $list = []; + return ['status_code' => 400]; } foreach ($list as $i => $l) { - if (null === ($l->approval = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$l->id)->orderBy('updated_at', 'desc')->get())) { - $l->approval = []; + if (null === ($l->approvals = MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', (int)$l->id)->orderBy('updated_at', 'desc')->get())) { + continue; } - foreach ($l->approval as $ii => $ra) { - if (null === ($l->approval[$ii]['child'] = Child::select($child_select)->where('id', (int)$l->approval[$ii]['child_id'])->first())) { - $l->approval[$ii]['child'] = []; + if (count($l->approvals->toArray()) != MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$l->id)->count()) { + continue; + } + + foreach ($l->approvals as $ii => $ll) { + if (null === ($ll->child = Child::select($child_select)->where('id', (int)$ll->child_id)->first())) { + $ll->child = new \stdClass(); + } + + if (!in_array($l, $result)) { + $result[] = $l; } } - - $result[] = $l; } return ['status_code' => 200, 'params' => $result]; @@ -329,21 +347,27 @@ class MeetingsController extends Controller { // 取得に成功 if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)$r->father_id)->where('is_favorite', 0)->get())) { - $list = []; + return ['status_code' => 400]; } foreach ($list as $i => $l) { - if (null === ($l->approval = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$l->id)->orderBy('updated_at', 'desc')->get())) { - $l->approval = []; + if (null === ($l->approvals = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$l->id)->orderBy('updated_at', 'desc')->get())) { + continue; } - foreach ($l->approval as $ii => $ra) { - if (null === ($l->approval[$ii]['child'] = Child::select($child_select)->where('id', (int)$l->approval[$ii]['child_id'])->first())) { - $l->approval[$ii]['child'] = []; + if (count($l->approvals) == MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', (int)$l->id)->count()) { + continue; + } + + foreach ($l->approvals as $ii => $ll) { + if (null === ($ll->child = Child::select($child_select)->where('id', (int)$ll->child_id)->first())) { + $ll->child = new \stdClass(); + } + + if (!in_array($l, $result)) { + $result[] = $l; } } - - $result[] = $l; } return ['status_code' => 200, 'params' => $result]; @@ -433,15 +457,21 @@ class MeetingsController extends Controller { } foreach ($list as $i => $l) { - if (null !== ($l->approvals = MeetingApprovals::select($meeting_approvals_select)->whereNull('approval_at')->where('meeting_id', (int)$l->id)->get())) { - foreach ($l->approvals as $ii => $ll) { - if (null === ($ll->child = Child::select($child_select)->where('id', (int)$ll->child_id)->first())) { - $ll->child = new \stdClass(); - } + if (null === ($l->approvals = MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', (int)$l->id)->get())) { + continue; + } - if (!in_array($l, $result)) { - $result[] = $l; - } + if (count($l->approvals->toArray()) != MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$l->id)->count()) { + continue; + } + + foreach ($l->approvals as $ii => $ll) { + if (null === ($ll->child = Child::select($child_select)->where('id', (int)$ll->child_id)->first())) { + $ll->child = new \stdClass(); + } + + if (!in_array($l, $result)) { + $result[] = $l; } } } @@ -465,15 +495,21 @@ class MeetingsController extends Controller { } foreach ($list as $i => $l) { - if (null !== ($l->approvals = MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', (int)$l->id)->get())) { - foreach ($l->approvals as $ii => $ll) { - if (null === ($ll->child = Child::select($child_select)->where('id', (int)$ll->child_id)->first())) { - $ll->child = new \stdClass(); - } + if (null === ($l->approvals = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$l->id)->get())) { + continue; + } - if (!in_array($l, $result)) { - $result[] = $l; - } + if (count($l->approvals) == MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', (int)$l->id)->count()) { + continue; + } + + foreach ($l->approvals as $ii => $ll) { + if (null === ($ll->child = Child::select($child_select)->where('id', (int)$ll->child_id)->first())) { + $ll->child = new \stdClass(); + } + + if (!in_array($l, $result)) { + $result[] = $l; } } }