detailに配列の追加

このコミットが含まれているのは:
守矢諏訪子 2021-11-03 02:30:46 +09:00
コミット e02124efe9
1個のファイルの変更10行の追加2行の削除

ファイルの表示

@ -13,6 +13,7 @@ use App\Models\MeetingImage;
use App\Models\MeetingApprovals;
use App\Models\Child;
use App\Models\Father;
use App\Models\FatherRelation;
class MeetingsController extends Controller {
public function register (Request $r) {
@ -468,6 +469,7 @@ class MeetingsController extends Controller {
$meeting_images_select = ['id', 'image'];
$meeting_approvals_select = ['approval_at', 'child_id'];
$child_select = ['image', 'last_name', 'first_name'];
$all_child_select = ['id as child_id', 'last_name', 'first_name'];
// 取得に成功
if (null === ($result = Meeting::select($meeting_select)->where('id', (int)$meeting_id)->first())) {
@ -475,10 +477,16 @@ class MeetingsController extends Controller {
}
if (null === ($result->meeting_image = MeetingImage::select($meeting_images_select)->where('meeting_id', (int)$result->id)->get())) {
return ['status_code' => 400];
$result->meeting_image = [];
}
if (null === ($result->approval = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$result->id)->whereNotNull('approval_at')->get())) {
return ['status_code' => 400];
$result->approval = [];
}
if (null !== ($rel = FatherRelation::select('child_id')->where('father_id', (int)$result->father_id)->first())) {
if (null === ($result->children = Child::select($all_child_select)->where('id', $rel->child_id)->get()->toArray())) {
$result->children = [];
}
}
foreach ($result->approval as $i => $a) {