From cf7bcc4e10e1c31c1ef678635ebe0104a2f816de 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: Sat, 8 Jan 2022 16:36:34 +0900 Subject: [PATCH 1/3] =?UTF-8?q?=E3=83=AA=E3=83=AC=E3=83=BC=E3=82=B7?= =?UTF-8?q?=E3=83=A7=E3=83=B3=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/FatherRelationsController.php | 15 ++++++++------- .../Http/Controllers/Api/MeetingsController.php | 2 +- backend/routes/api.php | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/backend/app/Http/Controllers/Api/FatherRelationsController.php b/backend/app/Http/Controllers/Api/FatherRelationsController.php index af0e2399..e40da154 100644 --- a/backend/app/Http/Controllers/Api/FatherRelationsController.php +++ b/backend/app/Http/Controllers/Api/FatherRelationsController.php @@ -15,17 +15,18 @@ use App\Models\Meeting; use App\Models\MeetingApprovals; class FatherRelationsController extends Controller { - public function check (Request $r) { - - $father_id = (int)$r->father_id; - - if (FatherRelation::select('id')->where('father_id', $father_id)->count() == 0) { + public function checkNull () { + if (FatherRelation::select('id')->where('father_id', (int)session()->get('fathers')['id'])->count() == 0) { return ['status_code' => 401, 'error_messages' => ['契約上限数に達した為、メンバー追加できません。']]; } - $father = Father::select('relation_limit')->where('id', $father_id)->first(); + return ['status_code' => 200]; + } - if ($father->relation_limit <= FatherRelation::select('id')->where('father_id', $father_id)->count()) { + public function check () { + $father = Father::select('relation_limit')->where('id', (int)session()->get('fathers')['id'])->first(); + + if ($father->relation_limit <= FatherRelation::select('id')->where('father_id', (int)session()->get('fathers')['id'])->count()) { return ['status_code' => 401, 'error_messages' => ['契約上限数に達した為、メンバー追加できません。']]; } diff --git a/backend/app/Http/Controllers/Api/MeetingsController.php b/backend/app/Http/Controllers/Api/MeetingsController.php index 81b0b120..754ba081 100644 --- a/backend/app/Http/Controllers/Api/MeetingsController.php +++ b/backend/app/Http/Controllers/Api/MeetingsController.php @@ -447,7 +447,7 @@ class MeetingsController extends Controller { $child_select = ['image']; // 取得に成功 - if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)session()->get('fathers')['id'])->where('is_favorite', 0)->orderBy('created_at', 'desc')->get())) { + if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)session()->get('fathers')['id'])->where('is_favorite', 0)->orderBy('updated_at', 'desc')->get())) { return ['status_code' => 400]; } diff --git a/backend/routes/api.php b/backend/routes/api.php index d0dd39f7..5bf34612 100644 --- a/backend/routes/api.php +++ b/backend/routes/api.php @@ -143,6 +143,7 @@ Route::group(['prefix' => 'fathers'], function () { // FatherRelationsController Route::group(['prefix' => 'relations'], function () { + Route::get('/checkNull', '\App\Http\Controllers\Api\FatherRelationsController@checkNull'); Route::get('/check', '\App\Http\Controllers\Api\FatherRelationsController@check'); Route::post('/register', '\App\Http\Controllers\Api\FatherRelationsController@register'); Route::put('/updateHireDate/{child_id}', '\App\Http\Controllers\Api\FatherRelationsController@updateHireDate'); From 4da87320c803e2ba572dcba343ecc91cf2412f13 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: Sat, 8 Jan 2022 16:41:49 +0900 Subject: [PATCH 2/3] updated_at --- .../app/Http/Controllers/Api/ChildrenController.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/backend/app/Http/Controllers/Api/ChildrenController.php b/backend/app/Http/Controllers/Api/ChildrenController.php index 06cbf928..0809961d 100644 --- a/backend/app/Http/Controllers/Api/ChildrenController.php +++ b/backend/app/Http/Controllers/Api/ChildrenController.php @@ -274,7 +274,7 @@ class ChildrenController extends Controller { return ['status_code' => 400, 'error_messages' => ['画像の更新に失敗しました。']]; } - if (null === ($result = Child::where('first_name', 'LIKE', '%'.$r->keyword.'%')->orWhere('last_name', 'LIKE', '%'.$r->keyword.'%')->orderBy('created_at', 'desc')->get())) { + if (null === ($result = Child::where('first_name', 'LIKE', '%'.$r->keyword.'%')->orWhere('last_name', 'LIKE', '%'.$r->keyword.'%')->orderBy('updated_at', 'desc')->get())) { // 親一覧の取得に失敗 return ['status_code' => 400]; } @@ -286,7 +286,7 @@ class ChildrenController extends Controller { public function list () { $child_select = ['id', 'first_name', 'last_name', 'tel', 'image']; - if (null === ($result = Child::select($child_select)->orderBy('created_at', 'desc')->get())) { + if (null === ($result = Child::select($child_select)->orderBy('updated_at', 'desc')->get())) { // 親一覧の取得に失敗 return ['status_code' => 400]; } @@ -302,7 +302,7 @@ class ChildrenController extends Controller { $result = []; $child_select = ['id', 'image', 'first_name', 'last_name', 'company', 'tel', 'email']; - if (null === ($list = FatherRelation::select('child_id')->where('father_id', (int)$r->father_id)->orderBy('created_at', 'desc')->get())) { + if (null === ($list = FatherRelation::select('child_id')->where('father_id', (int)$r->father_id)->orderBy('updated_at', 'desc')->get())) { return ['status_code' => 400]; } @@ -319,7 +319,7 @@ class ChildrenController extends Controller { $result = []; $child_select = ['id', 'image', 'last_name', 'first_name']; - if (null === ($list = MeetingApprovals::select('child_id')->where('meeting_id', (int)$r->meeting_id)->orderBy('created_at', 'desc')->get())) { + if (null === ($list = MeetingApprovals::select('child_id')->where('meeting_id', (int)$r->meeting_id)->orderBy('updated_at', 'desc')->get())) { return ['status_code' => 400]; } @@ -341,7 +341,7 @@ class ChildrenController extends Controller { $child_select = ['id', 'image', 'last_name', 'first_name', 'tel']; $meeting_approvals_select = ['approval_at']; - if (null === ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$r->meeting_id)->whereNull('approval_at')->orderBy('created_at', 'desc')->get())) { + if (null === ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$r->meeting_id)->whereNull('approval_at')->orderBy('updated_at', 'desc')->get())) { return ['status_code' => 400]; } @@ -364,7 +364,7 @@ class ChildrenController extends Controller { $child_select = ['id', 'image', 'last_name', 'first_name', 'tel']; $meeting_approvals_select = ['approval_at']; - if (null === ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNotNull('approval_at')->orderBy('created_at', 'desc')->get())) { + if (null === ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNotNull('approval_at')->orderBy('updated_at', 'desc')->get())) { return ['status_code' => 400]; } From 406607009bb3aa05aded45791f2620f069a0b62c 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: Sat, 8 Jan 2022 16:59:57 +0900 Subject: [PATCH 3/3] =?UTF-8?q?=E9=9B=BB=E8=A9=B1=E7=A2=BA=E8=AA=8D?= =?UTF-8?q?=E3=81=AEDB=E3=81=A7=E8=A6=AAID=E3=82=92=E6=B6=88=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/Models/TelActivation.php | 2 +- .../2021_08_13_050204_create_tel_activations_table.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/backend/app/Models/TelActivation.php b/backend/app/Models/TelActivation.php index 24b517dd..3902d68e 100644 --- a/backend/app/Models/TelActivation.php +++ b/backend/app/Models/TelActivation.php @@ -8,5 +8,5 @@ use Illuminate\Database\Eloquent\Model; class TelActivation extends Model { use HasFactory; - protected $fillable = ['type', 'child_id', 'father_id', 'tel', 'token', 'ttl']; + protected $fillable = ['type', 'child_id', 'tel', 'token', 'ttl']; } diff --git a/backend/database/migrations/2021_08_13_050204_create_tel_activations_table.php b/backend/database/migrations/2021_08_13_050204_create_tel_activations_table.php index 2c7fa5ca..6428ca31 100644 --- a/backend/database/migrations/2021_08_13_050204_create_tel_activations_table.php +++ b/backend/database/migrations/2021_08_13_050204_create_tel_activations_table.php @@ -18,8 +18,6 @@ class CreateTelActivationsTable extends Migration $table->unsignedTinyInteger('type'); $table->unsignedBigInteger('child_id')->nullable(); $table->foreign('child_id')->references('id')->on('children')->onDelete('cascade'); - $table->unsignedBigInteger('father_id')->nullable(); - $table->foreign('father_id')->references('id')->on('fathers')->onDelete('cascade'); $table->string('tel', 11)->unique(); $table->string('token', 100)->unique(); $table->dateTime('ttl');