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');