From fc02690db3602f0200e2d5429c9dd04d06ff2f4a 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, 30 Nov 2021 14:24:35 +0900 Subject: [PATCH] =?UTF-8?q?=E3=81=8A=E6=B0=97=E3=81=AB=E5=85=A5=E3=82=8A?= =?UTF-8?q?=E3=81=AB=E7=99=BB=E9=8C=B2=E3=81=97=E3=81=9F=E9=9A=9B=E3=80=81?= =?UTF-8?q?=E5=BE=8C=E3=81=8B=E3=82=89=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=9F?= =?UTF-8?q?=E5=AD=90=E3=81=AF=E5=85=A8=E3=81=A6=E3=83=AA=E3=83=AC=E3=83=BC?= =?UTF-8?q?=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=99=E3=82=8B=E4=BB=95=E6=A7=98?= =?UTF-8?q?=E3=81=A7=E3=81=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/FatherRelationsController.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/app/Http/Controllers/Api/FatherRelationsController.php b/backend/app/Http/Controllers/Api/FatherRelationsController.php index 586260dd..cfdb2791 100644 --- a/backend/app/Http/Controllers/Api/FatherRelationsController.php +++ b/backend/app/Http/Controllers/Api/FatherRelationsController.php @@ -9,6 +9,8 @@ use Illuminate\Support\Facades\Log; use App\Models\Child; use App\Models\FatherRelation; +use App\Models\Meeting; +use App\Models\MeetingApprovals; class FatherRelationsController extends Controller { public function register (Request $r) { @@ -37,6 +39,19 @@ class FatherRelationsController extends Controller { try { if (null === ($fr = FatherRelation::where('child_id', $child->id)->where('father_id', (int)$r->father_id)->first())) { FatherRelation::create($create); + if (null !== ($meet = Meeting::select('id', 'is_favorite')->where('father_id', (int)$r->father_id)->get())) { + foreach ($meet as $m) { + if ($m->is_favorite) { + $addapprove = [ + 'meeting_id' => $m->id, + 'child_id' => $child->id, + 'approval_at' => null, + ]; + + MeetingApprovals::create($addapprove); + } + } + } } else { return ['status_code' => 400, 'error_messages' => ['すでに追加されました']];