From 661a7409a6f3f0a3daf798acbf805f3b87617c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=86=E3=82=AF=E3=83=8B=E3=82=AB=E3=83=AB=E8=AB=8F?= =?UTF-8?q?=E8=A8=AA=E5=AD=90?= Date: Tue, 16 Nov 2021 18:02:03 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E4=B8=80=E8=A6=A7=E3=80=81=E6=A4=9C?= =?UTF-8?q?=E7=B4=A2=E3=80=81=E6=B0=97=E3=81=AB=E5=85=A5=E3=82=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/MeetingsController.php | 132 +++++++++++------- 1 file changed, 84 insertions(+), 48 deletions(-) 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; } } } From 8fb4ac36b827970e72a5817e6d725a0ddc561d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=86=E3=82=AF=E3=83=8B=E3=82=AB=E3=83=AB=E8=AB=8F?= =?UTF-8?q?=E8=A8=AA=E5=AD=90?= Date: Tue, 16 Nov 2021 18:53:47 +0900 Subject: [PATCH 2/3] =?UTF-8?q?=E3=83=91=E3=83=A9=E3=83=A1=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=83=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/Http/Controllers/Api/ChildrenController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/app/Http/Controllers/Api/ChildrenController.php b/backend/app/Http/Controllers/Api/ChildrenController.php index 41b82ed2..b7dedb83 100644 --- a/backend/app/Http/Controllers/Api/ChildrenController.php +++ b/backend/app/Http/Controllers/Api/ChildrenController.php @@ -254,7 +254,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]; From e90eabc542eb0a892a2ae8c74c66a01988542c08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=86=E3=82=AF=E3=83=8B=E3=82=AB=E3=83=AB=E8=AB=8F?= =?UTF-8?q?=E8=A8=AA=E5=AD=90?= Date: Tue, 16 Nov 2021 18:57:48 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E8=AA=AC=E6=98=8E=E6=9B=B8=E3=81=AB?= =?UTF-8?q?=E3=82=88=E3=81=A3=E3=81=A6=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/Http/Controllers/Api/ChildrenController.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/app/Http/Controllers/Api/ChildrenController.php b/backend/app/Http/Controllers/Api/ChildrenController.php index b7dedb83..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]; }