Merge pull request #59 from nakazawakan/lofhenko

listOfFatherの変更
このコミットが含まれているのは:
chankan77 2021-11-01 17:45:32 +09:00 committed by GitHub
コミット 554aade1ae
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: 4AEE18F83AFDEB23
1個のファイルの変更9行の追加6行の削除

ファイルの表示

@ -180,17 +180,20 @@ class ChildrenController extends Controller {
return ['status_code' => 200, 'params' => $result];
}
public function listOfFather (Request $r) {
public function listOfFather ($father_id) {
if (!isset($father_id)) {
return ['status_code' => 400];
}
$result = [];
$child_select = ['id', 'image', 'last_name', 'first_name'];
$child_select = ['first_name', 'last_name', 'tel'];
if (null === ($list = FatherRelation::select('father_id')->where('father_id', (int)$r->father_id)->orderBy('created_at', 'desc')->get())) {
if (null === ($list = FatherRelation::select('child_id')->where('father_id', (int)$father_id)->orderBy('created_at', 'desc')->get())) {
return ['status_code' => 400];
}
foreach ($list as $l) {
if (null === ($result[] = Child::select($child_select)->find($l->father_id))) {
return ['status_code' => 400];
foreach ($list as $i => $l) {
if (null === ($result[] = Child::select($child_select)->where('id', $l->child_id)->first())) {
$result[$i] = [];
}
}