michiakiさんのアドバイス

このコミットが含まれているのは:
守矢諏訪子 2021-10-07 13:51:53 +09:00
コミット 30d47f5b6c
5個のファイルの変更367行の追加299行の削除

ファイルの表示

@ -18,43 +18,47 @@ class ChildrenController extends Controller {
public function requestPassword () {}
public function list () {
// 親一覧の取得に成功
if ($result = Child::orderBy('created_at', 'desc')->get()->toArray()) {
return ['status_code' => 200, 'params' => $result];
if (null === ($result = Child::orderBy('created_at', 'desc')->get())) {
// 親一覧の取得に失敗
return ['status_code' => 400];
}
// 親一覧の取得に失敗
return ['status_code' => 400];
// 親一覧の取得に成功
return ['status_code' => 200, 'params' => $result];
}
public function listOfFather (Request $r) {
$result = [];
$child_select = ['id', 'image', 'last_name', 'first_name'];
if ($list = FatherRelation::where('father_id', $r->father_id)->orderBy('created_at', 'desc')->get()->toArray()) {
foreach ($list as $l) {
$result[] = Child::select($child_select)->find($l['father_id']);
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = FatherRelation::select('father_id')->where('father_id', $r->father_id)->orderBy('created_at', 'desc')->get())) {
return ['status_code' => 400];
}
return ['status_code' => 400];
foreach ($list as $l) {
if (null === ($result[] = Child::select($child_select)->find($l->father_id))) {
return ['status_code' => 400];
}
}
return ['status_code' => 200, 'params' => $result];
}
public function listOfMeeting (Request $r) {
$result = [];
$child_select = ['id', 'image', 'last_name', 'first_name'];
if ($list = MeetingApprovals::where('meeting_id', $r->meeting_id)->orderBy('created_at', 'desc')->get()->toArray()) {
foreach ($list as $l) {
$result[] = Child::select($child_select)->find($l['id']);
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = MeetingApprovals::select('child_id')->where('meeting_id', $r->meeting_id)->orderBy('created_at', 'desc')->get())) {
return ['status_code' => 400];
}
return ['status_code' => 400];
foreach ($list as $l) {
if (null === ($result[] = Child::select($child_select)->find($l->child_id))) {
return ['status_code' => 400];
}
}
return ['status_code' => 200, 'params' => $result];
}
public function listOfMeetingNotifyUnapprovel (Request $r) {
@ -66,16 +70,18 @@ class ChildrenController extends Controller {
$child_select = ['id', 'image', 'last_name', 'first_name', 'tel'];
$meeting_approvals_select = ['approval_at'];
if ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNull('approval_at')->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = Child::select($child_select)->where('id', $l['child_id'])->get();
$result[$i]['meeting_approval'] = $l['approval_at'];
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNull('approval_at')->get())) {
return ['status_code' => 400];
}
return ['status_code' => 400];
foreach ($list as $i => $l) {
if (null === ($result[] = Child::select($child_select)->where('id', $l->child_id)->get())) {
return ['status_code' => 400];
}
$result[$i]['meeting_approval'] = $l->approval_at;
}
return ['status_code' => 200, 'params' => $result];
}
public function listOfMeetingNotifyApprovel (Request $r) {
@ -87,16 +93,18 @@ class ChildrenController extends Controller {
$child_select = ['id', 'image', 'last_name', 'first_name', 'tel'];
$meeting_approvals_select = ['approval_at'];
if ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNotNull('approval_at')->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = Child::select($child_select)->where('id', $l['child_id'])->get();
$result[$i]['meeting_approval'] = $l['approval_at'];
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNotNull('approval_at')->get())) {
return ['status_code' => 400];
}
return ['status_code' => 400];
foreach ($list as $i => $l) {
if (null === ($result[] = Child::select($child_select)->where('id', $l->child_id)->get())) {
return ['status_code' => 400];
}
$result[$i]['meeting_approval'] = $l->approval_at;
}
return ['status_code' => 200, 'params' => $result];
}
public function detail (Request $r, $child_id) {
@ -105,19 +113,22 @@ class ChildrenController extends Controller {
$father_relation_select = ['hire_at'];
// 親詳細の取得に成功
if ($list = Child::where('id', $child_id)->orderBy('created_at', 'desc')->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = Child::select($child_select)->find($l['id']);
if (isset($r->father_id)) {
$result[$i]['father_relation'] = FatherRelation::select($father_relation_select)->where('father_id', $r->father_id)->first();
}
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = Child::select('id')->where('id', $child_id)->orderBy('created_at', 'desc')->get())) {
return ['status_code' => 400];
}
// 親詳細の取得に失敗
return ['status_code' => 400];
foreach ($list as $i => $l) {
if (null === ($result[] = Child::select($child_select)->find($l->id))) {
return ['status_code' => 400];
}
if (isset($r->father_id)) {
if (null === ($result[$i]['father_relation'] = FatherRelation::select($father_relation_select)->where('father_id', $r->father_id)->first())) {
return ['status_code' => 400];
}
}
}
return ['status_code' => 200, 'params' => $result];
}
public function updateImage (Request $r, $child_id) {
@ -208,11 +219,14 @@ class ChildrenController extends Controller {
public function withdrawal ($child_id) {
// 削除成功
if (Child::where('id', $child_id)->delete()) {
return ['status_code' => 200];
try {
Child::where('id', $child_id)->delete();
} catch (\Throwable $e) {
Log::critical($e->getMessage());
return ['status_code' => 400];
}
// 削除失敗
return ['status_code' => 400];
return ['status_code' => 200];
}
}

ファイルの表示

@ -20,49 +20,51 @@ class FathersController extends Controller {
$father_select = ['id', 'company', 'image'];
$father_relation_select = ['created_at'];
// 親一覧の取得に成功
if ($list = Father::select($father_select)->orderBy('created_at', 'desc')->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['relation'] = FatherRelation::select($father_relation_select)->where('father_id', $l['id'])->first();
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = Father::select($father_select)->orderBy('created_at', 'desc')->get())) {
// 親一覧の取得に失敗
return ['status_code' => 400];
}
// 親一覧の取得に失敗
return ['status_code' => 400];
foreach ($list as $i => $l) {
$result[] = $l;
if (null === ($result[$i]['relation'] = FatherRelation::select($father_relation_select)->where('father_id', $l->id)->first())) {
return ['status_code' => 400];
}
}
// 親一覧の取得に成功
return ['status_code' => 200, 'params' => $result];
}
public function listOfChild (Request $r) {
$result = [];
$father_select = ['id', 'company', 'image'];
// 親一覧の取得に成功
if ($list = FatherRelation::where('child_id', $r->child_id)->orderBy('created_at', 'desc')->get()->toArray()) {
$result = [];
foreach ($list as $l) {
$result[] = Father::select($father_select)->find($l['father_id']);
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = FatherRelation::select('father_id')->where('child_id', $r->child_id)->orderBy('created_at', 'desc')->get())) {
// 親一覧の取得に失敗
return ['status_code' => 400];
}
// 親一覧の取得に失敗
return ['status_code' => 400];
foreach ($list as $l) {
if (null === ($result[] = Father::select($father_select)->find($l->father_id))) {
return ['status_code' => 400];
}
}
// 親一覧の取得に成功
return ['status_code' => 200, 'params' => $result];
}
public function detail ($father_id) {
$father_select = ['id', 'email', 'company', 'image', 'tel'];
// 親詳細の取得に成功
if ($result = Father::select($father_select)->where('id', $father_id)->orderBy('created_at', 'desc')->get()->toArray()) {
return ['status_code' => 200, 'params' => $result];
if (null === ($result = Father::select($father_select)->where('id', $father_id)->orderBy('created_at', 'desc')->get())) {
// 親詳細の取得に失敗
return ['status_code' => 400];
}
// 親詳細の取得に失敗
return ['status_code' => 400];
// 親詳細の取得に成功
return ['status_code' => 200, 'params' => $result];
}
public function updateImage (Request $r, $father_id) {
@ -152,22 +154,28 @@ class FathersController extends Controller {
}
public function withdrawal ($father_id) {
// 成功
if (Father::where('id', $father_id)->delete()) {
return ['status_code' => 200, 'success_messages' => ['親の削除に成功しました。']];
try {
Father::where('id', $father_id)->delete();
} catch (\Throwable $e) {
// 失敗
Log::critical($e->getMessage());
return ['status_code' => 400, 'error_messages' => ['親の削除に失敗しました。']];
}
// 失敗
return ['status_code' => 400, 'error_messages' => ['親の削除に失敗しました。']];
// 成功
return ['status_code' => 200, 'success_messages' => ['親の削除に成功しました。']];
}
public function delete ($meeting_id) {
// 成功
if (Meeting::where('id', $meeting_id)->delete()) {
return ['status_code' => 200, 'success_messages' => ['ミーティングを削除に成功しました。']];
try {
Meeting::where('id', $meeting_id)->delete();
} catch (\Throwable $e) {
// 失敗
Log::critical($e->getMessage());
return ['status_code' => 400, 'error_messages' => ['ミーティングの削除に失敗しました。']];
}
// 失敗
return ['status_code' => 400, 'error_messages' => ['ミーティングの削除に失敗しました。']];
// 成功
return ['status_code' => 200, 'success_messages' => ['ミーティングを削除に成功しました。']];
}
}

ファイルの表示

@ -48,20 +48,18 @@ class MeetingApprovalsController extends Controller {
$meeting_approvals_select = ['id', 'child_id', 'approval_at'];
$child_select = ['id', 'image', 'last_name', 'first_name'];
// meeting_idでミーティングの許可があれば
if ($params = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNotNull('approval_at')->get()) {
// 子を付いてみて。child_idがなければ、すぐ400になります。
foreach ($params as $p) {
if (!$p->child_id = Child::select($child_select)->where('id', $p->child_id)->first()) {
return ['status' => 400];
}
}
return ['status' => 200, 'params' => $params];
if (null === ($params = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNotNull('approval_at')->get())) {
// エラーの場合
return ['status' => 400];
}
// エラーの場合
return ['status' => 400];
foreach ($params as $p) {
if (null === ($p->child_id = Child::select($child_select)->where('id', $p->child_id)->first())) {
return ['status' => 400];
}
}
return ['status' => 200, 'params' => $params];
}
public function listChildrenOfUnapprovel (Request $r) {
@ -72,20 +70,18 @@ class MeetingApprovalsController extends Controller {
$meeting_select = ['id', 'child_id', 'approval_at'];
$child_select = ['id', 'image', 'last_name', 'first_name'];
// meeting_idでミーティングの許可がなければ
if ($params = MeetingApprovals::select($meeting_select)->where('meeting_id', $r->meeting_id)->whereNull('approval_at')->get()) {
// 子を付いてみて。child_idがなければ、すぐ400になります。
foreach ($params as $p) {
if (!$p->child_id = Child::select($child_select)->where('id', $p->child_id)->first()) {
return ['status' => 400];
}
}
return ['status' => 200, 'params' => $params];
if (null === ($params = MeetingApprovals::select($meeting_select)->where('meeting_id', $r->meeting_id)->whereNull('approval_at')->get())) {
// エラーの場合
return ['status' => 400];
}
// エラーの場合
return ['status' => 400];
foreach ($params as $p) {
if (null === ($p->child_id = Child::select($child_select)->where('id', $p->child_id)->first())) {
return ['status' => 400];
}
}
return ['status' => 200, 'params' => $params];
}
public function deleteRelationMeeting ($meeting_id) {
@ -93,13 +89,14 @@ class MeetingApprovalsController extends Controller {
return ['status_code' => 400];
}
// 削除成功
if (MeetingApprovals::where('meeting_id', $meeting_id)->delete()) {
return ['status_code' => 200];
try {
MeetingApprovals::where('meeting_id', $meeting_id)->delete();
} catch (\Throwable $e) {
Log::critical($e->getMessage());
return ['status_code' => 400];
}
// 削除失敗
return ['status_code' => 400];
return ['status_code' => 200];
}
public function deleteRelationChild ($child_id) {
@ -107,12 +104,13 @@ class MeetingApprovalsController extends Controller {
return ['status_code' => 400];
}
// 削除成功
if (MeetingApprovals::where('child_id', $child_id)->delete()) {
return ['status_code' => 200];
try {
MeetingApprovals::where('child_id', $child_id)->delete();
} catch (\Throwable $e) {
Log::critical($e->getMessage());
return ['status_code' => 400];
}
// 削除失敗
return ['status_code' => 400];
return ['status_code' => 200];
}
}

ファイルの表示

@ -42,23 +42,15 @@ class MeetingImagesController extends Controller {
return ['status_code' => 200];
}
public function delete ($meeting_id) {
// 削除成功
if (MeetingImage::where('meeting_id', $meeting_id)->delete()) {
return ['status_code' => 200];
}
// 削除失敗
return ['status_code' => 400];
}
public function deleteRelationMeeting ($meeting_id) {
// 削除成功
if (MeetingImage::where('meeting_id', $meeting_id)->delete()) {
return ['status_code' => 200];
try {
MeetingImage::where('meeting_id', $meeting_id)->delete();
} catch (\Throwable $e) {
// 失敗
Log::critical($e->getMessage());
return ['status_code' => 400];
}
// 削除失敗
return ['status_code' => 400];
return ['status_code' => 200];
}
}

ファイルの表示

@ -55,11 +55,15 @@ class MeetingsController extends Controller {
$update = ['is_favorite' => $r->is_favorite];
if (Meeting::where('id', $r->meeting_id)->update($update)) {
return ['status_code' => 200];
try {
Meeting::where('id', $r->meeting_id)->update($update);
} catch (\Throwable $e) {
// 失敗
Log::critical($e->getMessage());
return ['status_code' => 400];
}
return ['status_code' => 400];
return ['status_code' => 200];
}
public function list () {
@ -71,19 +75,24 @@ class MeetingsController extends Controller {
$meeting_approvals_select = ['approval_at'];
// 取得に成功
if ($list = Meeting::select($meeting_select)->orderBy('created_at', 'desc')->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['meeting_images'] = MeetingImage::select($meeting_images_select)->where('meeting_id', $l['id'])->get();
$result[$i]['fathers'] = Father::select($father_select)->where('id', $l['father_id'])->get();
$result[$i]['meeting_approvals'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l['id'])->orderBy('approval_at', 'desc')->get();
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = Meeting::select($meeting_select)->orderBy('created_at', 'desc')->get())) {
return ['status_code' => 400];
}
// 取得に失敗
return ['status_code' => 400];
foreach ($list as $i => $l) {
$result[] = $l;
if (null === ($result[$i]['meeting_images'] = MeetingImage::select($meeting_images_select)->where('meeting_id', $l->id)->get())) {
return ['status_code' => 400];
}
if (null === ($result[$i]['fathers'] = Father::select($father_select)->where('id', $l->father_id)->get())) {
return ['status_code' => 400];
}
if (null === ($result[$i]['meeting_approvals'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l->id)->orderBy('approval_at', 'desc')->get())) {
return ['status_code' => 400];
}
}
return ['status_code' => 200, 'params' => $result];
}
public function listOfApprovalOfChild (Request $r) {
@ -98,23 +107,30 @@ class MeetingsController extends Controller {
$meeting_approvals_select = ['approval_at'];
// 取得に成功
if ($approval = MeetingApprovals::where('child_id', $r->child_id)->whereNotNull('approval_at')->orderBy('updated_at', 'desc')->get()) {
foreach ($approval as $a) {
if ($list = Meeting::select($meeting_select)->where('id', $a->meeting_id)->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['meeting_images'] = MeetingImage::select($meeting_images_select)->where('meeting_id', $l['id'])->get();
$result[$i]['fathers'] = Father::select($father_select)->where('id', $l['father_id'])->get();
$result[$i]['meeting_approvals'] = MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', $l['id'])->orderBy('updated_at', 'desc')->get();
}
if (null === ($approval = MeetingApprovals::select('meeting_id')->where('child_id', $r->child_id)->whereNotNull('approval_at')->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
return ['status_code' => 200, 'params' => $result];
foreach ($approval as $a) {
if (null === ($list = Meeting::select($meeting_select)->where('id', $a->meeting_id)->get())) {
return ['status_code' => 400];
}
foreach ($list as $i => $l) {
$result[] = $l;
if (null === ($result[$i]['meeting_images'] = MeetingImage::select($meeting_images_select)->where('meeting_id', $l->id)->get())) {
return ['status_code' => 400];
}
if (null === ($result[$i]['fathers'] = Father::select($father_select)->where('id', $l->father_id)->get())) {
return ['status_code' => 400];
}
if (null === ($result[$i]['meeting_approvals'] = MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', $l->id)->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
}
}
// 取得に失敗
return ['status_code' => 400];
return ['status_code' => 200, 'params' => $result];
}
public function listOfNonApprovalOfChild (Request $r) {
@ -129,23 +145,30 @@ class MeetingsController extends Controller {
$meeting_approvals_select = ['approval_at'];
// 取得に成功
if ($approval = MeetingApprovals::where('child_id', $r->child_id)->whereNull('approval_at')->orderBy('approval_at', 'asc')->get()) {
foreach ($approval as $a) {
if ($list = Meeting::select($meeting_select)->where('id', $a->meeting_id)->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['meeting_images'] = MeetingImage::select($meeting_images_select)->where('meeting_id', $l['id'])->get();
$result[$i]['fathers'] = Father::select($father_select)->where('id', $l['father_id'])->get();
$result[$i]['meeting_approvals'] = MeetingApprovals::select($meeting_approvals_select)->whereNull('approval_at')->where('meeting_id', $l['id'])->orderBy('approval_at', 'asc')->get();
}
if (null === ($approval = MeetingApprovals::select('meeting_id')->where('child_id', $r->child_id)->whereNull('approval_at')->orderBy('approval_at', 'asc')->get())) {
return ['status_code' => 400];
}
return ['status_code' => 200, 'params' => $result];
foreach ($approval as $a) {
if (null === ($list = Meeting::select($meeting_select)->where('id', $a->meeting_id)->get())) {
return ['status_code' => 400];
}
foreach ($list as $i => $l) {
$result[] = $l;
if (null === ($result[$i]['meeting_images'] = MeetingImage::select($meeting_images_select)->where('meeting_id', $l->id)->get())) {
return ['status_code' => 400];
}
if (null === ($result[$i]['fathers'] = Father::select($father_select)->where('id', $l->father_id)->get())) {
return ['status_code' => 400];
}
if (null === ($result[$i]['meeting_approvals'] = MeetingApprovals::select($meeting_approvals_select)->whereNull('approval_at')->where('meeting_id', $l->id)->orderBy('approval_at', 'asc')->get())) {
return ['status_code' => 400];
}
}
}
// 取得に失敗
return ['status_code' => 400];
return ['status_code' => 200, 'params' => $result];
}
public function listOfCompleteOfFather (Request $r) {
@ -159,25 +182,27 @@ class MeetingsController extends Controller {
$child_select = ['image'];
// 取得に成功
if ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['approvals'] = MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', $l['id'])->orderBy('updated_at', 'desc')->get();
if (count($result[$i]['approvals']) == 0) {
unset($result[$i]);
continue;
}
foreach ($result[$i]['approvals'] as $ii => $ra) {
$result[$i]['approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['approvals'][$ii]['child_id'])->first();
}
if (null === ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->get())) {
return ['status_code' => 400];
}
foreach ($list as $i => $l) {
$result[] = $l;
if (null === ($result[$i]['approvals'] = MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', $l->id)->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
if (count($result[$i]['approvals']) == 0) {
unset($result[$i]);
continue;
}
return ['status_code' => 200, 'params' => $result];
foreach ($result[$i]['approvals'] as $ii => $ra) {
if (null === ($result[$i]['approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['approvals'][$ii]['child_id'])->first())) {
return ['status_code' => 400];
}
}
}
// 取得に失敗
return ['status_code' => 400];
return ['status_code' => 200, 'params' => $result];
}
public function listOfIncompleteOfFather (Request $r) {
@ -191,25 +216,28 @@ class MeetingsController extends Controller {
$child_select = ['image'];
// 取得に成功
if ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['approvals'] = MeetingApprovals::select($meeting_approvals_select)->whereNull('approval_at')->where('meeting_id', $l['id'])->orderBy('updated_at', 'desc')->get();
if (count($result[$i]['approvals']) > 1) {
unset($result[$i]);
continue;
}
foreach ($result[$i]['approvals'] as $ii => $ra) {
$result[$i]['approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['approvals'][$ii]['child_id'])->first();
}
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->get())) {
return ['status_code' => 400];
}
// 取得に失敗
return ['status_code' => 400];
foreach ($list as $i => $l) {
$result[] = $l;
if (null === ($result[$i]['approvals'] = MeetingApprovals::select($meeting_approvals_select)->whereNull('approval_at')->where('meeting_id', $l->id)->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
if (count($result[$i]['approvals']) > 1) {
unset($result[$i]);
continue;
}
foreach ($result[$i]['approvals'] as $ii => $ra) {
if (null === ($result[$i]['approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['approvals'][$ii]['child_id'])->first())) {
return ['status_code' => 400];
}
}
}
return ['status_code' => 200, 'params' => $result];
}
public function listOfFavoriteofFather (Request $r) {
@ -223,21 +251,24 @@ class MeetingsController extends Controller {
$child_select = ['image'];
// 取得に成功
if ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->where('is_favorite', 1)->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['approvals'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l['id'])->orderBy('updated_at', 'desc')->get();
foreach ($result[$i]['approvals'] as $ii => $ra) {
$result[$i]['approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['approvals'][$ii]['child_id'])->first();
}
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->where('is_favorite', 1)->get())) {
return ['status_code' => 400];
}
// 取得に失敗
return ['status_code' => 400];
foreach ($list as $i => $l) {
$result[] = $l;
if (null === ($result[$i]['approvals'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l->id)->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
foreach ($result[$i]['approvals'] as $ii => $ra) {
if (null === ($result[$i]['approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['approvals'][$ii]['child_id'])->first())) {
return ['status_code' => 400];
}
}
}
return ['status_code' => 200, 'params' => $result];
}
public function listOfNonFavoriteofFather (Request $r) {
@ -251,21 +282,24 @@ class MeetingsController extends Controller {
$child_select = ['image'];
// 取得に成功
if ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->where('is_favorite', 0)->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['approvals'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l['id'])->orderBy('updated_at', 'desc')->get();
foreach ($result[$i]['approvals'] as $ii => $ra) {
$result[$i]['approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['approvals'][$ii]['child_id'])->first();
}
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->where('is_favorite', 0)->get())) {
return ['status_code' => 400];
}
// 取得に失敗
return ['status_code' => 400];
foreach ($list as $i => $l) {
$result[] = $l;
if (null === ($result[$i]['approvals'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l->id)->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
foreach ($result[$i]['approvals'] as $ii => $ra) {
if (null === ($result[$i]['approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['approvals'][$ii]['child_id'])->first())) {
return ['status_code' => 400];
}
}
}
return ['status_code' => 200, 'params' => $result];
}
public function searchOfApprovalOfChild (Request $r) {
@ -279,18 +313,21 @@ class MeetingsController extends Controller {
$meeting_approvals_select = ['approval_at as date'];
// 取得に成功
if ($list = Meeting::select($meeting_select)->where('title', 'LIKE', '%'.$r->keyword.'%')->orWhere('text', 'LIKE', '%'.$r->keyword.'%')->get()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['father'] = Father::select($father_select)->where('id', $l['father_id'])->first();
$result[$i]['approval'] = MeetingApprovals::select($meeting_approvals_select)->where('child_id', $r->child_id)->whereNotNull('approval_at')->get();
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = Meeting::select($meeting_select)->where('title', 'LIKE', '%'.$r->keyword.'%')->orWhere('text', 'LIKE', '%'.$r->keyword.'%')->get())) {
return ['status_code' => 400];
}
// 取得に失敗
return ['status_code' => 400];
foreach ($list as $i => $l) {
$result[] = $l;
if (null === ($result[$i]['father'] = Father::select($father_select)->where('id', $l->father_id)->first())) {
return ['status_code' => 400];
}
if (null === ($result[$i]['approval'] = MeetingApprovals::select($meeting_approvals_select)->where('child_id', $r->child_id)->whereNotNull('approval_at')->get())) {
return ['status_code' => 400];
}
}
return ['status_code' => 200, 'params' => $result];
}
public function searchOfNonApprovalOfChild (Request $r) {
@ -304,18 +341,21 @@ class MeetingsController extends Controller {
$meeting_approvals_select = ['approval_at as date'];
// 取得に成功
if ($list = Meeting::select($meeting_select)->where('title', 'LIKE', '%'.$r->keyword.'%')->orWhere('text', 'LIKE', '%'.$r->keyword.'%')->get()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['father'] = Father::select($father_select)->where('id', $l['father_id'])->first();
$result[$i]['approval'] = MeetingApprovals::select($meeting_approvals_select)->where('child_id', $r->child_id)->whereNull('approval_at')->get();
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = Meeting::select($meeting_select)->where('title', 'LIKE', '%'.$r->keyword.'%')->orWhere('text', 'LIKE', '%'.$r->keyword.'%')->get())) {
return ['status_code' => 400];
}
// 取得に失敗
return ['status_code' => 400];
foreach ($list as $i => $l) {
$result[] = $l;
if (null === ($result[$i]['father'] = Father::select($father_select)->where('id', $l->father_id)->first())) {
return ['status_code' => 400];
}
if (null === ($result[$i]['approval'] = MeetingApprovals::select($meeting_approvals_select)->where('child_id', $r->child_id)->whereNull('approval_at')->get())) {
return ['status_code' => 400];
}
}
return ['status_code' => 200, 'params' => $result];
}
public function searchOfCompleteofFather (Request $r) {
@ -330,22 +370,27 @@ class MeetingsController extends Controller {
$child_select = ['image'];
// 取得に成功
if ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->where('title', 'LIKE', '%'.$r->keyword.'%')->orWhere('text', 'LIKE', '%'.$r->keyword.'%')->get()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['meeting_image'] = MeetingImage::select($meeting_images_select)->where('meeting_id', $l['id'])->get();
$result[$i]['meeting_approvals'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l['id'])->whereNull('approval_at')->get();
foreach ($result[$i]['meeting_approvals'] as $ii => $ra) {
$result[$i]['meeting_approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['meeting_approvals'][$ii]['child_id'])->first();
}
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->where('title', 'LIKE', '%'.$r->keyword.'%')->orWhere('text', 'LIKE', '%'.$r->keyword.'%')->get())) {
return ['status_code' => 400];
}
// 取得に失敗
return ['status_code' => 400];
foreach ($list as $i => $l) {
$result[] = $l;
if (null == ($result[$i]['meeting_image'] = MeetingImage::select($meeting_images_select)->where('meeting_id', $l->id)->get())) {
return ['status_code' => 400];
}
if (null == ($result[$i]['meeting_approvals'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l->id)->whereNull('approval_at')->get())) {
return ['status_code' => 400];
}
foreach ($result[$i]['meeting_approvals'] as $ii => $ra) {
if (null == ($result[$i]['meeting_approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['meeting_approvals'][$ii]['child_id'])->first())) {
return ['status_code' => 400];
}
}
}
return ['status_code' => 200, 'params' => $result];
}
public function searchOfIncompleteofFather (Request $r) {
@ -360,22 +405,27 @@ class MeetingsController extends Controller {
$child_select = ['image'];
// 取得に成功
if ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->where('title', 'LIKE', '%'.$r->keyword.'%')->orWhere('text', 'LIKE', '%'.$r->keyword.'%')->get()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['meeting_image'] = MeetingImage::select($meeting_images_select)->where('meeting_id', $l['id'])->get();
$result[$i]['meeting_approvals'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l['id'])->whereNotNull('approval_at')->get();
foreach ($result[$i]['meeting_approvals'] as $ii => $ra) {
$result[$i]['meeting_approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['meeting_approvals'][$ii]['child_id'])->first();
}
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->where('title', 'LIKE', '%'.$r->keyword.'%')->orWhere('text', 'LIKE', '%'.$r->keyword.'%')->get())) {
return ['status_code' => 400];
}
// 取得に失敗
return ['status_code' => 400];
foreach ($list as $i => $l) {
$result[] = $l;
if (null === ($result[$i]['meeting_image'] = MeetingImage::select($meeting_images_select)->where('meeting_id', $l->id)->get())) {
return ['status_code' => 400];
}
if (null === ($result[$i]['meeting_approvals'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l->id)->whereNotNull('approval_at')->get())) {
return ['status_code' => 400];
}
foreach ($result[$i]['meeting_approvals'] as $ii => $ra) {
if (null === ($result[$i]['meeting_approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['meeting_approvals'][$ii]['child_id'])->first())) {
return ['status_code' => 400];
}
}
}
return ['status_code' => 200, 'params' => $result];
}
public function detail (Request $r, $meeting_id) {
@ -390,31 +440,37 @@ class MeetingsController extends Controller {
$child_select = ['image'];
// 取得に成功
if ($list = Meeting::select($meeting_select)->where('id', $meeting_id)->where('father_id', $r->father_id)->get()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['meeting_image'] = MeetingImage::select($meeting_images_select)->where('meeting_id', $l['id'])->get();
$result[$i]['meeting_approvals'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l['id'])->whereNotNull('approval_at')->get();
foreach ($result[$i]['meeting_approvals'] as $ii => $ra) {
$result[$i]['meeting_approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['meeting_approvals'][$ii]['child_id'])->first();
}
}
return ['status_code' => 200, 'params' => $result];
if (null === ($list = Meeting::select($meeting_select)->where('id', $meeting_id)->where('father_id', $r->father_id)->get())) {
return ['status_code' => 400];
}
// 取得に失敗
return ['status_code' => 400];
foreach ($list as $i => $l) {
$result[] = $l;
if (null === ($result[$i]['meeting_image'] = MeetingImage::select($meeting_images_select)->where('meeting_id', $l->id)->get())) {
return ['status_code' => 400];
}
if (null === ($result[$i]['meeting_approvals'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l->id)->whereNotNull('approval_at')->get())) {
return ['status_code' => 400];
}
foreach ($result[$i]['meeting_approvals'] as $ii => $ra) {
if (null === ($result[$i]['meeting_approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['meeting_approvals'][$ii]['child_id'])->first())) {
return ['status_code' => 400];
}
}
}
return ['status_code' => 200, 'params' => $result];
}
public function delete ($meeting_id) {
// 削除成功
if (Meetings::where('meeting_id', $meeting_id)->delete()) {
return ['status_code' => 200];
try {
Meetings::where('meeting_id', $meeting_id)->delete();
} catch (\Throwable $e) {
Log::critical($e->getMessage());
return ['status_code' => 400];
}
// 削除失敗
return ['status_code' => 400];
return ['status_code' => 200];
}
}