meetings/detailで親のデータ(子画面限定)

このコミットが含まれているのは:
守矢諏訪子 2021-11-05 18:51:10 +09:00
コミット 1ec50700f7
1個のファイルの変更15行の追加6行の削除

ファイルの表示

@ -152,7 +152,7 @@ class MeetingsController extends Controller {
$l->meeting_images = [];
}
if (null === ($l->fathers = Father::select($father_select)->where('id', (int)$l->father_id)->first())) {
$l->fathers = new \stdObject();
$l->fathers = new \stdClass();
}
if (null === ($l->meeting_approvals = MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', (int)$l->id)->orderBy('updated_at', 'desc')->get())) {
$l->meeting_approvals = [];
@ -190,7 +190,7 @@ class MeetingsController extends Controller {
$l->meeting_images = [];
}
if (null === ($l->fathers = Father::select($father_select)->where('id', (int)$l->father_id)->first())) {
$l->fathers = new \stdObject();
$l->fathers = new \stdClass();
}
if (null === ($l->meeting_approvals = MeetingApprovals::select($meeting_approvals_select)->whereNull('approval_at')->where('meeting_id', (int)$l->id)->orderBy('approval_at', 'asc')->get())) {
$l->meeting_approvals = [];
@ -472,7 +472,8 @@ class MeetingsController extends Controller {
$meeting_select = ['id', 'father_id', 'title', 'text', 'memo', 'pdf', 'updated_at', 'is_favorite'];
$meeting_images_select = ['id', 'image'];
$meeting_approvals_select = ['approval_at', 'child_id'];
$child_select = ['image', 'last_name', 'first_name'];
$father_select = ['image', 'company', 'tel'];
$child_select = ['id', 'image', 'last_name', 'first_name', 'tel'];
$all_child_select = ['id as child_id', 'last_name', 'first_name'];
// 取得に成功
@ -487,6 +488,12 @@ class MeetingsController extends Controller {
$result->approval = [];
}
if (request()->session()->get('children')) {
if (null === ($result->father = Father::select($father_select)->where('id', (int)$result->father_id)->first())) {
$result->father = new \stdClass();
}
}
$result->children = [];
if (null !== ($rel = FatherRelation::select('child_id')->where('father_id', (int)$result->father_id)->first())) {
@ -495,9 +502,11 @@ class MeetingsController extends Controller {
}
}
foreach ($result->approval as $i => $a) {
if (null === ($result->approval[$i]['child'] = Child::select($child_select)->where('id', (int)$a->child_id)->first())) {
$result->approval[$i]['child'] = [];
if (request()->session()->get('fathers') || request()->session()->get('admins')) {
foreach ($result->approval as $i => $a) {
if (null === ($result->approval[$i]['child'] = Child::select($child_select)->where('id', (int)$a->child_id)->first())) {
$result->approval[$i]['child'] = [];
}
}
}