diff --git a/backend/app/Http/Controllers/Api/AdminController.php b/backend/app/Http/Controllers/Api/AdminController.php new file mode 100644 index 00000000..0362ec15 --- /dev/null +++ b/backend/app/Http/Controllers/Api/AdminController.php @@ -0,0 +1,68 @@ +session()->has('email')) { + return redirect()->intended(); + } + + // if (null === $r->server('HTTP_USER_AGENT')) { + // return ['status_code' => 400, 'error_message' => ['不正なuser_agent。']]; + // } + + // if (null !== ($ll = LoginLimits::where('user_agent', $r->server('HTTP_USER_AGENT'))->first())) { + // if ((time() >= strtotime($ll->updated_at) + 600) === false) { + // LoginLimits::where('user_agent', $r->server('HTTP_USER_AGENT'))->delete(); + // } + // if ($ll->fail_number >= 10) { + // return ['status_code' => 400, 'error_message' => ['10回連続で失敗しましたので、10分、ログインロックになりました。']]; + // } + // } + + $validate = Validator::make($r->all(), [ + 'email' => 'required|max:255|email', + 'password' => 'required|min:8|max:72', + ]); + + if ($validate->fails()) { + // バリデーションエラー + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } + + // 存在しない場合 + if (null === ($admin = Admin::select('id', 'email', 'password')->where('email', $r->email)->first())) { + return ['status_code' => 400, 'error_message' => ['このアカウントが存在しません。']]; + } + + // パスワードが異なる場合 + if (!Hash::check($r->password, $admin->password)) { + // if ($ll = LoginLimits::where('user_agent', $r->server('HTTP_USER_AGENT'))->first()) { + // LoginLimits::where('user_agent', $r->server('HTTP_USER_AGENT'))->update(['fail_number' => $ll->fail_number+1]); + // } + // else { + // LoginLimits::create(['user_agent' => $r->server('HTTP_USER_AGENT'), 'fail_number' => 1]); + // } + return ['status_code' => 400, 'error_message' => ['ログインに失敗しました。10回連続で失敗すると、一定期間ログインできなくなります。']]; + } + + // セッションを想像する + $r->session()->put('email', $admin->email); + return ['status_code' => 200]; + } + + public function logout (Request $r) { + // セッションを破壊する + $r->session()->forget('email'); + return ['status_code' => 200]; + } +} diff --git a/backend/app/Http/Controllers/Api/ChildrenController.php b/backend/app/Http/Controllers/Api/ChildrenController.php index f60b702c..4395e2b7 100644 --- a/backend/app/Http/Controllers/Api/ChildrenController.php +++ b/backend/app/Http/Controllers/Api/ChildrenController.php @@ -3,102 +3,334 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; +use Illuminate\Support\Facades\Validator; +use Illuminate\Support\Facades\Hash; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; use App\Models\Child; use App\Models\FatherRelation; use App\Models\MeetingApprovals; -use Exception; +use App\Models\TelActivations; class ChildrenController extends Controller { - public function login () {} + public function login () {} - public function registerTemporary () {} - - public function registerMain () {} - - public function checkTel () {} - - public function list () { - // 親一覧の取得に成功 - if ($result = Child::orderBy('created_at', 'desc')->get()->toArray()) { - return ['status_code' => 200, 'params' => $result]; - } - - // 親一覧の取得に失敗 - return ['status_code' => 400]; - } - - public function listOfFather (Request $r) { - $result = []; - $child_select = ['id', 'image', 'last_name', 'first_name', 'company']; - - 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['child_id']); - } - - return ['status_code' => 200, 'params' => $result]; - } - - return ['status_code' => 400]; - } - - 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]; - } - - return ['status_code' => 400]; - } - - public function listOfMeetingNotifyUnapprovel () {} - - public function listOfMeetingNotifyApprovel () {} - - public function detail (Request $r, $child_id) { - $result = []; - $child_select = ['email', 'tel', 'last_name', 'first_name', 'image', 'company']; - $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(); + public function registerTemporary (Request $r) { + $validate = Validator::make($r->all(), [ + 'tel' => 'required|unique:children|max:11|numeric|starts_with:0' + ]); + if ($validate->fails()) { + // バリデーションエラー + return ['status_code' => 422, 'error_messages' => $validate->errors()]; } - } - return ['status_code' => 200, 'params' => $result]; + if ($get = TelActivations::where('tel', $r->tel)->first()) { + // すでにDBに登録されている場合 + return ['status_code' => 400, 'error_messages' => ['既に使用されている電話番号です。']]; + } + + $token = random_bytes(16); + $insert = ['tel' => $r->tel, 'token' => $token]; + + try { + Child::create($insert); + } catch (\Throwable $e) { + // 失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'error_messages' => ['登録に失敗しました。']]; + } + + // TODO: SMSの送信、SMSコントローラーを作る後でします。 + // try { + // $sms = new SMS; + // if (!$sms->send($r->tel, $token)) { + // // SMSの送信に失敗した場合 + // return ['status_code' => 401, 'error_messages' => ['SMSの送信に失敗しました。電話番号が正しいかご確認ください。']]; + // } + // } catch { + // // SMS APIのエラーの場合 + // Log::critical($e->getMessage()); + // return ['status_code' => 402, 'error_messages' => ['予期せぬエラーが発生しました。管理者へお問い合わせください。']]; + // } + + // 仮登録に成功した場合 + return ['status_code' => 200, 'params' => ['tel' => $r->tel]]; } - // 親詳細の取得に失敗 - return ['status_code' => 400]; - } + public function registerMain (Request $r) { + $validate = Validator::make($r->all(), [ + 'token' => 'required', + 'email' => 'required|unique:children|max:255|email', + 'password' => 'required|min:8|max:72|confirmed', + 'last_name' => 'required|max:100', + 'first_name' => 'required|max:100', + 'identity' => 'required|max:20|alpha_num', + 'image' => 'max:1024|mimes:jpg,png,gif', + 'company' => 'max:100', + ]); + if ($validate->fails()) { + // バリデーションエラー + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } - public function updateImage ($child_id) {} + $password = Hash::make($r->password); - public function updateProfile ($child_id) {} + // 有効期限が切れている場合 + if ($get = TelActivations::where('token', $r->token)->first() && strtotime($get->ttl) > time()) { + return ['status_code' => 400, 'error_messages' => ['仮登録の有効期限が切れました。改めて親にお問い合わせいただき、再登録の手続きを行ってください。']]; + } - public function updatePassword ($child_id) {} + $insert = [ + 'email' => $r->email, + 'tel' => $get->tel, + 'tel_verified_at' => date('Y-m-d H:i:s'), + 'password' => $password, + 'last_name' => $r->last_name, + 'first_name' => $r->first_name, + 'identity' => $r->identity, + 'image' => $r->image, + 'company' => $r->company, + ]; - public function delete ($child_id) { - try{ - // 削除成功 - if (Child::where('id', $child_id)->delete()) { + try { + Child::create($insert); + } catch (\Throwable $e) { + // 失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'error_messages' => ['登録に失敗しました。']]; + } + + // 本登録に成功 + return ['status_code' => 200, 'success_messages' => ['本登録に成功しました。'], 'params' => ['tel' => $r->tel, 'password' => $password]]; + } + + public function requestPassword () {} + + public function search (Request $r) { + if (!isset($r->keyword)) { + return ['status_code' => 400, 'error_messages' => ['画像の更新に失敗しました。']]; + } + + if (null === ($result = Child::where('first_name', 'LIKE', '%'.$r->keyword.'%')->orWhere('last_name', 'LIKE', '%'.$r->keyword.'%')->orderBy('created_at', 'desc')->get())) { + // 親一覧の取得に失敗 + return ['status_code' => 400]; + } + + // 親一覧の取得に成功 + return ['status_code' => 200, 'params' => $result]; + } + + public function list () { + if (null === ($result = Child::orderBy('created_at', 'desc')->get())) { + // 親一覧の取得に失敗 + 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 (null === ($list = FatherRelation::select('father_id')->where('father_id', $r->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]; + } + } + + return ['status_code' => 200, 'params' => $result]; + } + + public function listOfMeeting (Request $r) { + $result = []; + $child_select = ['id', 'image', 'last_name', 'first_name']; + + if (null === ($list = MeetingApprovals::select('child_id')->where('meeting_id', $r->meeting_id)->orderBy('created_at', 'desc')->get())) { + 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) { + if (!isset($r->meeting_id)) { + return ['status_code' => 400, 'error_messages' => ['画像の更新に失敗しました。']]; + } + + $result = []; + $child_select = ['id', 'image', 'last_name', 'first_name', 'tel']; + $meeting_approvals_select = ['approval_at']; + + if (null === ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNull('approval_at')->get())) { + 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) { + if (!isset($r->meeting_id)) { + return ['status_code' => 400, 'error_messages' => ['画像の更新に失敗しました。']]; + } + + $result = []; + $child_select = ['id', 'image', 'last_name', 'first_name', 'tel']; + $meeting_approvals_select = ['approval_at']; + + if (null === ($list = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNotNull('approval_at')->get())) { + 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) { + $result = []; + $child_select = ['email', 'tel', 'last_name', 'first_name', 'image', 'company']; + $father_relation_select = ['hire_at']; + + // 親詳細の取得に成功 + if (null === ($list = Child::select('id')->where('id', $child_id)->orderBy('created_at', 'desc')->get())) { + 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) { + if (!isset($child_id)) { + return ['status_code' => 400, 'error_messages' => ['画像の更新に失敗しました。']]; + } + + // バリデーションエラー + $validate = Validator::make($r->all(), ['image' => 'max:1024|mimes:jpg,png,gif']); + + if ($validate->fails()) { + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } + + try { + Child::where('id', $child_id)->update($r->all()); + } catch (\Throwable $e) { + // 失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'error_messages' => ['画像の更新に失敗しました。']]; + } + + // 成功 + return ['status_code' => 200, 'success_messages' => ['画像の更新に成功しました。']]; + } + + public function updateProfile (Request $r, $child_id) { + if (!isset($child_id)) { + return ['status_code' => 400, 'error_messages' => ['子の更新に失敗しました。']]; + } + + // バリデーションエラー + $validate = Validator::make($r->all(), [ + 'email' => 'required|unique:children|max:255|email|alpha_num', + 'tel' => 'required|unique:children|max:11|numeric|starts_with:0', + 'last_name' => 'required|max:100', + 'first_name' => 'required|max:100', + 'company' => 'max:100', + ]); + + if ($validate->fails()) { + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } + + try { + Child::where('id', $child_id)->update($r->all()); + } catch (\Throwable $e) { + // 失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'error_messages' => ['子の更新に失敗しました。']]; + } + + // 成功 + return ['status_code' => 200, 'success_messages' => ['子の更新に成功しました。']]; + } + + public function updatePassword (Request $r, $child_id) { + if (!isset($child_id)) { + return ['status_code' => 400, 'error_messages' => ['画像の更新に失敗しました。']]; + } + + // バリデーションエラー + $validate = Validator::make($r->all(), [ + 'password' => 'required|min:8|max:72|confirmed', + ]); + + $validate->after(function ($validate) { + if (count($r->image) > 10) { + $validate->errors()->add('count', '10枚以上登録できません。'); + } + }); + + if ($validate->fails()) { + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } + + try { + Child::where('id', $child_id)->update($r->all()); + } catch (\Throwable $e) { + // 失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'error_messages' => ['パスワードの更新に失敗しました。']]; + } + + // 成功 + return ['status_code' => 200, 'success_messages' => ['パスワードの更新に成功しました。']]; + } + + public function withdrawal ($child_id) { + // 削除成功 + try { + Child::where('id', $child_id)->delete(); + } catch (\Throwable $e) { + Log::critical($e->getMessage()); + return ['status_code' => 400]; + } + + // 削除失敗 return ['status_code' => 200]; - } - } catch (Exception $e) { - // 削除失敗 - return ['status_code' => 400, 'error' => $e->getMessage()]; } - } } diff --git a/backend/app/Http/Controllers/Api/ContactsController.php b/backend/app/Http/Controllers/Api/ContactsController.php index 2076c012..746935c8 100644 --- a/backend/app/Http/Controllers/Api/ContactsController.php +++ b/backend/app/Http/Controllers/Api/ContactsController.php @@ -29,7 +29,7 @@ class ContactsController extends Controller { } catch (\Throwable $e) { // 失敗 Log::critical($e->getMessage()); - return ['status_code' => 400, 'error_messages' => 'お問い合わせの送信に失敗しました。']; + return ['status_code' => 400, 'error_messages' => ['お問い合わせの送信に失敗しました。']]; } // 成功 diff --git a/backend/app/Http/Controllers/Api/EmailActivationsController.php b/backend/app/Http/Controllers/Api/EmailActivationsController.php deleted file mode 100644 index 6294ffd5..00000000 --- a/backend/app/Http/Controllers/Api/EmailActivationsController.php +++ /dev/null @@ -1,19 +0,0 @@ -delete()) { - return ['status_code' => 200]; - } - - // 削除失敗 - return ['status_code' => 400]; - } -} diff --git a/backend/app/Http/Controllers/Api/FatherRelationsController.php b/backend/app/Http/Controllers/Api/FatherRelationsController.php index 1981634b..4bf46133 100644 --- a/backend/app/Http/Controllers/Api/FatherRelationsController.php +++ b/backend/app/Http/Controllers/Api/FatherRelationsController.php @@ -4,59 +4,26 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; use App\Models\FatherRelation; class FatherRelationsController extends Controller { - public function register (Request $r) { - if (!isset($r->child_id) || !isset($r->father_id) || !isset($r->hire_at)) { - return ['status_code' => 400, 'success_messages' => '子の登録に失敗しました。']; - } - - $insert = [ - 'father_id' => $r->father_id, - 'child_id' => $r->child_id, - 'hire_at' => date('Y-m-d H:i:s', strtotime($r->hire_at)) - ]; - - if (FatherRelation::create($insert)) { - return ['status_code' => 200, 'success_messages' => '子の登録に成功しました。']; - } - - return ['status_code' => 400, 'success_messages' => '子の登録に失敗しました。']; - } - public function updateHireDate (Request $r, $child_id) { if (!isset($child_id) || !isset($r->father_id) || !isset($r->hire_at)) { - return ['status_code' => 400, 'success_messages' => '子の入社日の更新に失敗しました。']; + return ['status_code' => 400, 'success_messages' => ['子の入社日の更新に失敗しました。']]; } $update = ['hire_at' => date('Y-m-d H:i:s', strtotime($r->hire_at))]; - if (FatherRelation::where('father_id', $r->father_id)->where('child_id', $child_id)->update($update)) { - return ['status_code' => 200, 'success_messages' => '子の入社日の更新に成功しました。']; + try { + FatherRelation::where('father_id', $r->father_id)->where('child_id', $child_id)->update($update); + } catch (\Throwable $e) { + // 失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'success_messages' => ['子の入社日の更新に失敗しました。']]; } - return ['status_code' => 400, 'success_messages' => '子の入社日の更新に失敗しました。']; - } - - public function deleteRelationFather ($father_id) { - // 削除成功 - if (FatherRelation::where('father_id', $father_id)->delete()) { - return ['status_code' => 200]; - } - - // 削除失敗 - return ['status_code' => 400]; - } - - public function deleteRelationChild ($child_id) { - // 削除成功 - if (FatherRelation::where('child_id', $child_id)->delete()) { - return ['status_code' => 200]; - } - - // 削除失敗 - return ['status_code' => 400]; + return ['status_code' => 200, 'success_messages' => ['子の入社日の更新に成功しました。']]; } } diff --git a/backend/app/Http/Controllers/Api/FathersController.php b/backend/app/Http/Controllers/Api/FathersController.php index d007b698..77f363ad 100644 --- a/backend/app/Http/Controllers/Api/FathersController.php +++ b/backend/app/Http/Controllers/Api/FathersController.php @@ -3,83 +3,289 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; +use Illuminate\Support\Facades\Validator; +use Illuminate\Support\Facades\Hash; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; use App\Models\Father; use App\Models\FatherRelation; +use App\Models\EmailActivations; class FathersController extends Controller { - public function login () {} + public function login () {} - public function registerTemporary () {} + public function requestPassword () {} - public function registerMain () {} + public function registerTemporary (Request $r) { + $validate = Validator::make($r->all(), [ + 'email' => 'required|unique:father,email_activations|max:255|email|alpha_num' + ]); - public function list () { - $result = []; - $father_select = ['id', 'company', 'image']; - $father_relation_select = ['created_at']; + if ($validate->fails()) { + // バリデーションエラー + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } - // 親一覧の取得に成功 - 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(); - } + if ($get = Father::where('email', $r->email)->first()) { + // すでにDBに登録されている場合 + return ['status_code' => 400, 'error_messages' => ['入力したメールアドレスは既に登録済みです。同じメールアドレスは使用できません。']]; + } + else if ($get = EmailActivations::where('email', $r->email)->first()) { + // すでにDBに登録されている場合 + return ['status_code' => 400, 'error_messages' => ['入力したメールアドレスは既に登録済みです。同じメールアドレスは使用できません。']]; + } + else { + $chars = 'abcdefghijklmnopqrstuvwxyz0123456789'; + $token = ''; + for ($i = 1; $i < 15; $i++) { + $token .= $chars[rand(0,35)]; + } - return ['status_code' => 200, 'params' => $result]; + $create = ['email' => $r->email, 'token' => $token, 'ttl' => date('Y-m-d H:i:s', time()+28800)]; + + try { + EmailActivations::create($create); + } catch (\Throwable $e) { + // 失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'error_messages' => '登録に失敗しました。']; + } + } + + // 仮登録に成功した場合 + return ['status_code' => 200, 'token' => $token, 'success_messages' => ['親の仮登録に成功しました。8時間以内に本登録を完了させてください。']]; } - // 親一覧の取得に失敗 - return ['status_code' => 400]; - } + public function registerMain (Request $r) { + $validate = Validator::make($r->all(), [ + 'token' => 'required', + 'password' => 'required|min:8|max:72|confirmed', + 'company' => 'max:100', + 'image' => 'max:1024|mimes:jpg,png,gif', + 'profile' => 'max:1000', + 'tel' => 'required|unique:children|max:11|numeric|starts_with:0', + ]); + if ($validate->fails()) { + // バリデーションエラー + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } - public function listOfChild (Request $r) { - $result = []; - $father_select = ['id', 'company', 'image']; + $password = Hash::make($r->password); - // 親一覧の取得に成功 - if ($list = FatherRelation::where('child_id', $r->child_id)->orderBy('created_at', 'desc')->get()->toArray()) { - $result = []; + if ($get = EmailActivations::where('token', $r->token)->first() && strtotime($get->ttl) > time()) { + // 有効期限が切れている場合 + return['status_code' => 401, 'error_messages' => ['仮登録の有効期限が切れました。改めて管理者にお問い合わせいただき、再登録を行ってください。']]; + } - foreach ($list as $l) { - $result[] = Father::select($father_select)->find($l['father_id']); - } + try { + $create = [ + 'email' => $get->email, + 'email_verified_at' => date('Y-m-d H:i:s'), + 'password' => $password, + 'company' => $r->company, + 'image' => $r->image, + 'profile' => $r->profile, + 'tel' => $r->tel, + ]; - return ['status_code' => 200, 'params' => $result]; + Father::create($create); + } catch (\Throwable $e) { + // 本登録に失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'error_messages' => ['本登録に失敗しました。']]; + } + + // 本登録に成功 + return ['status_code' => 200]; } - // 親一覧の取得に失敗 - return ['status_code' => 400]; - } + public function search (Request $r) { + if (!isset($r->keyword)) { + return ['status_code' => 400]; + } - public function detail ($father_id) { - $father_select = ['id', 'email', 'company', 'image', 'tel', 'profile']; + $result = []; + $father_select = ['id', 'company', 'image']; + $father_relation_select = ['created_at']; - // 親詳細の取得に成功 - if ($result = Father::select($father_select)->where('id', $father_id)->orderBy('created_at', 'desc')->get()->toArray()) { - return ['status_code' => 200, 'params' => $result]; + if (null === ($list = Father::select($father_select)->where('company', 'LIKE', '%'.$r->keyword.'%')->orderBy('created_at', 'desc')->get())) { + // 親一覧の取得に失敗 + 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]; } - // 親詳細の取得に失敗 - return ['status_code' => 400]; - } + public function list () { + $result = []; + $father_select = ['id', 'company', 'image']; + $father_relation_select = ['created_at']; - public function updateImage ($father_id) {} + if (null === ($list = Father::select($father_select)->orderBy('created_at', 'desc')->get())) { + // 親一覧の取得に失敗 + return ['status_code' => 400]; + } - public function updateProfile ($father_id) {} + 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]; + } + } - public function updatePassword ($father_id) {} - - public function delete ($father_id) { - // 削除成功 - if (Father::where('id', $father_id)->delete()) { - return ['status_code' => 200]; + // 親一覧の取得に成功 + return ['status_code' => 200, 'params' => $result]; } - // 削除失敗 - return ['status_code' => 400]; - } + public function listOfChild (Request $r) { + $result = []; + $father_select = ['id', 'company', 'image']; - public function checkEmail () {} + if (null === ($list = FatherRelation::select('father_id')->where('child_id', $r->child_id)->orderBy('created_at', 'desc')->get())) { + // 親一覧の取得に失敗 + 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 = ['image', 'email', 'tel', 'profile', 'company']; + + if (null === ($result = Father::select($father_select)->where('id', $father_id)->orderBy('created_at', 'desc')->get()->toArray())) { + // 親詳細の取得に失敗 + return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']]; + } + + // 親詳細の取得に成功 + return ['status_code' => 200, 'params' => $result]; + } + + public function updateImage (Request $r, $father_id) { + if (!isset($r->image) || !isset($father_id)) { + return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']]; + } + + // バリデーションエラー + $validate = Validator::make($r->all(), ['image' => 'max:1024|mimes:jpg,png,gif']); + // 300x300px + + if ($validate->fails()) { + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } + + try { + Father::where('id', $father_id)->update($r->all()); + } catch (\Throwable $e) { + // 親プロフィール画像のアップロードに失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']]; + } + + // 親プロフィール画像のアップロードに成功 + return ['status_code' => 200, 'success_messages' => ['親の更新に成功しました。']]; + } + + public function updateProfile (Request $r, $father_id) { + if (!isset($father_id)) { + return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']]; + } + + // バリデーションエラー + $validate = Validator::make($r->all(), [ + 'email' => 'required|unique:fathers|max:255|email|alpha_num', + 'company' => 'max:100', + 'profile' => 'max:1000', + 'tel' => 'required|unique:fathers|max:11|numeric|starts_with:0', + ]); + + if ($validate->fails()) { + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } + + try { + Father::where('id', $father_id)->update($r->all()); + } catch (\Throwable $e) { + // 親プロフィール更新失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']]; + } + + // 親プロフィール更新成功 + return ['status_code' => 200, 'success_messages' => ['親の更新に成功しました。']]; + } + + public function updatePassword (Request $r, $father_id) { + if (!isset($r->image) || !isset($father_id)) { + return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']]; + } + + // バリデーションエラー + $validate = Validator::make($r->all(), [ + 'password' => 'required|min:8|max:72|confirmed', + ]); + + $validate->after(function ($validate) { + if (count($r->image) > 10) { + $validate->errors()->add('count', '10枚以上登録できません。'); + } + }); + + if ($validate->fails()) { + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } + + try { + Father::where('id', $father_id)->update($r->all()); + } catch (\Throwable $e) { + // 失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'error_messages' => ['親の更新に失敗しました。']]; + } + + // 成功 + return ['status_code' => 200, 'success_messages' => ['親の更新に成功しました。']]; + } + + public function withdrawal ($father_id) { + try { + Father::where('id', $father_id)->delete(); + } catch (\Throwable $e) { + // 失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'error_messages' => ['親の削除に失敗しました。']]; + } + + // 成功 + return ['status_code' => 200, 'success_messages' => ['親の削除に成功しました。']]; + } + + public function delete ($meeting_id) { + try { + Meeting::where('id', $meeting_id)->delete(); + } catch (\Throwable $e) { + // 失敗 + Log::critical($e->getMessage()); + return ['status_code' => 400, 'error_messages' => ['親の削除に失敗しました。']]; + } + + // 成功 + return ['status_code' => 200, 'success_messages' => ['親の削除に成功しました。']]; + } } diff --git a/backend/app/Http/Controllers/Api/LoginLimitsController.php b/backend/app/Http/Controllers/Api/LoginLimitsController.php deleted file mode 100644 index 1e321cdd..00000000 --- a/backend/app/Http/Controllers/Api/LoginLimitsController.php +++ /dev/null @@ -1,46 +0,0 @@ -user_agent)) { - return ['status_code' => 400, 'error_messages' => 'ユーザーエイジェントを読めません。']; - } - - // 受取 - if ($get = LoginLimits::where('user_agent', $r->user_agent)->first()) { - // 失敗数は10以上だと、エラーを出します。以内の場合、失敗数を増えます。 - if ($get->fail_number >= 10) { - return ['status_code' => 400, 'error_messages' => 'ログインに失敗しました。10回連続で失敗すると、一定期間ログインできなくなります。']; - } - else { - $update = ['fail_number' => $get->fail_number+1]; - LoginLimits::where('user_agent', $r->user_agent)->update($update); - } - } - else { - // まだこのuser_agentがなければ、追加します。 - $create = ['user_agent' => $r->user_agent, 'fail_number' => 1]; - LoginLimits::create($create); - } - - return ['status' => 200]; - } - - public function delete (Request $r) { - // 削除成功 - if (LoginLimits::where('user_agent', $r->user_agent)->delete()) { - return ['status_code' => 200]; - } - - // 削除失敗 - return ['status_code' => 400]; - } -} diff --git a/backend/app/Http/Controllers/Api/MeetingApprovalsController.php b/backend/app/Http/Controllers/Api/MeetingApprovalsController.php index e043571f..b76c781c 100644 --- a/backend/app/Http/Controllers/Api/MeetingApprovalsController.php +++ b/backend/app/Http/Controllers/Api/MeetingApprovalsController.php @@ -4,71 +4,115 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; use App\Models\Child; use App\Models\Meeting; use App\Models\MeetingApprovals; +use App\Models\FatherRelation; class MeetingApprovalsController extends Controller { - public function register (Request $r) {} - - public function registerOfApproval (Request $r) {} - - public function listChildrenOfMeeting (Request $r) {} - - public function listChildrenOfApprovel (Request $r) { - $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)->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]; + public function registerApproval (Request $r) { + if (!isset($r->meeting_id) || !isset($r->child_id)) { + return ['status' => 400, 'error_messages' => ['承認に失敗しました。']]; } - } - return ['status' => 200, 'params' => $params]; + if (MeetingApprovals::where('id', $r->meeting_id)->where('child_id', $r->child_id)->first()) { + return ['status_code' => 200, 'success_messages' => ['承認しました。']]; + } + + return ['status_code' => 400, 'error_messages' => ['承認に失敗しました。']]; } - // エラーの場合 - return ['status' => 400]; - } - - public function listChildrenOfUnapprovel (Request $r) { - $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]; + public function listChildrenOfMeeting (Request $r) { + if (!isset($r->meeting_id) || !isset($r->child_id)) { + return ['status' => 400, 'error_messages' => ['承認に失敗しました。']]; } - } - return ['status' => 200, 'params' => $params]; + $meeting_approvals_select = ['id', 'child_id', 'approval_at']; + $update = ['hire_at' => date('Y-m-d H:i:s', strtotime($r->hire_at))]; + + if ($params = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->where('child_id', $r->child_id)->get()) { + if (FatherRelation::where('child_id', $r->child_id)->update($update)) { + return ['status' => 200, 'success_messages' => ['承認しました。']]; + } + } + + // エラーの場合 + return ['status' => 400, 'error_messages' => ['承認に失敗しました。']]; } - // エラーの場合 - return ['status' => 400]; - } + public function listChildrenOfApprovel (Request $r) { + if (!isset($r->meeting_id)) { + return ['status_code' => 400]; + } - public function deleteRelationMeeting ($meeting_id) { - // 削除成功 - if (MeetingApprovals::where('meeting_id', $meeting_id)->delete()) return ['status_code' => 200]; + $meeting_approvals_select = ['id', 'child_id', 'approval_at']; + $child_select = ['id', 'image', 'last_name', 'first_name']; - // 削除失敗 - return ['status_code' => 400]; - } + if (null === ($params = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $r->meeting_id)->whereNotNull('approval_at')->get())) { + // エラーの場合 + return ['status' => 400]; + } - public function deleteRelationChild ($child_id) { - // 削除成功 - if (MeetingApprovals::where('child_id', $child_id)->delete()) return ['status_code' => 200]; + foreach ($params as $p) { + if (null === ($p->child_id = Child::select($child_select)->where('id', $p->child_id)->first())) { + return ['status' => 400]; + } + } - // 削除失敗 - return ['status_code' => 400]; - } + return ['status' => 200, 'params' => $params]; + } + + public function listChildrenOfUnapprovel (Request $r) { + if (!isset($r->meeting_id)) { + return ['status_code' => 400]; + } + + $meeting_select = ['id', 'child_id', 'approval_at']; + $child_select = ['id', 'image', 'last_name', 'first_name']; + + if (null === ($params = MeetingApprovals::select($meeting_select)->where('meeting_id', $r->meeting_id)->whereNull('approval_at')->get())) { + // エラーの場合 + 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) { + if (!isset($meeting_id)) { + return ['status_code' => 400]; + } + + try { + MeetingApprovals::where('meeting_id', $meeting_id)->delete(); + } catch (\Throwable $e) { + Log::critical($e->getMessage()); + return ['status_code' => 400]; + } + + return ['status_code' => 200]; + } + + public function deleteRelationChild ($child_id) { + if (!isset($child_id)) { + return ['status_code' => 400]; + } + + try { + MeetingApprovals::where('child_id', $child_id)->delete(); + } catch (\Throwable $e) { + Log::critical($e->getMessage()); + return ['status_code' => 400]; + } + + return ['status_code' => 200]; + } } diff --git a/backend/app/Http/Controllers/Api/MeetingImagesController.php b/backend/app/Http/Controllers/Api/MeetingImagesController.php index 3c075e05..ec43ced2 100644 --- a/backend/app/Http/Controllers/Api/MeetingImagesController.php +++ b/backend/app/Http/Controllers/Api/MeetingImagesController.php @@ -3,13 +3,18 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; -use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; use App\Models\MeetingImage; class MeetingImagesController extends Controller { public function register (Request $r) { + if (!isset($r->meeting_id)) { + return ['status' => 400]; + } + foreach ($r->all() as $i) { $validate = Validator::make($i, ['image' => 'file|max:1024|mimes:jpg,png,gif']); } @@ -24,10 +29,14 @@ class MeetingImagesController extends Controller { return ['status_code' => 422, 'error_messages' => $validate->errors()]; } - $create = ['meeting_id' => $meeting_id, 'image' => $image]; + $insert = ['meeting_id' => $meeting_id, 'image' => $image]; foreach ($r->images as $image) { - if (!MeetingImage::create($create)) { + try { + MeetingImage::create($insert); + } catch (\Throwable $e) { + // 失敗 + Log::critical($e->getMessage()); return ['status_code' => 400]; } } @@ -35,12 +44,14 @@ class MeetingImagesController extends Controller { } 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]; } } diff --git a/backend/app/Http/Controllers/Api/MeetingsController.php b/backend/app/Http/Controllers/Api/MeetingsController.php index de071adb..535c453e 100644 --- a/backend/app/Http/Controllers/Api/MeetingsController.php +++ b/backend/app/Http/Controllers/Api/MeetingsController.php @@ -3,8 +3,9 @@ namespace App\Http\Controllers\Api; use App\Http\Controllers\Controller; -use Illuminate\Http\Request; use Illuminate\Support\Facades\Validator; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Log; use App\Models\Meeting; use App\Models\MeetingImage; @@ -15,33 +16,37 @@ use App\Models\Father; class MeetingsController extends Controller { public function register (Request $r) { if (!isset($r->father_id)) { - return ['status_code' => 400, 'error_messages' => 'ミーティングの登録に失敗しました。']; + return ['status_code' => 400, 'error_messages' => ['ミーティングの登録に失敗しました。']]; } $validate = Validator::make($r->all(), [ - 'title' => 'required|max:100', - 'text' => 'required|max:2000', - 'memo' => 'max:2000', - 'pdf' => 'mimes:pdf' + 'title' => 'required|max:100', + 'text' => 'required|max:2000', + 'memo' => 'max:2000', + 'pdf' => 'mimes:pdf' ]); if ($validate->fails()) { return ['status_code' => 422, 'error_messages' => $validate->errors()]; } - $create = [ - 'father_id' => $r->father_id, - 'title' => $r->title, - 'text' => $r->text, - 'memo' => $r->memo, - 'pdf' => $r->pdf + $insert = [ + 'father_id' => $r->father_id, + 'title' => $r->title, + 'text' => $r->text, + 'memo' => $r->memo, + 'pdf' => $r->pdf ]; - if (Child::create($create)) { - return ['status_code' => 200, 'success_messages' => 'ミーティングの登録に成功しました。']; + try { + Child::create($insert); + } 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 registerFavorite (Request $r) { @@ -51,35 +56,72 @@ 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 search (Request $r) { + if (!isset($r->keyword)) { + return ['status_code' => 400]; + } + $result = []; + $meeting_select = ['id', 'title', 'text', 'updated_at']; + $child_select = ['image']; + $meeting_approvals_select = ['child_id', 'approval_at']; + + // 取得に成功 + if (null === ($list = Meeting::select($meeting_select)->where('title', 'LIKE', '%'.$r->keyword.'%')->orWhere('text', 'LIKE', '%'.$r->keyword.'%')->orderBy('created_at', 'desc')->get())) { + return ['status_code' => 400]; + } + + foreach ($list as $i => $l) { + $result[] = $l; + if (null === ($result[$i]['approval'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l->id)->orderBy('approval_at', 'desc')->get())) { + return ['status_code' => 400]; + } + + foreach ($result[$i]['approval'] as $j => $k) { + if (null === ($result[$i]['approval'][$j]['child'] = Child::select($child_select)->where('id', $k->child_id)->first())) { + return ['status_code' => 400]; + } + } + } + + return ['status_code' => 200, 'params' => $result]; } public function list () { - // TODO:adminsのみ $result = []; - $meeting_select = ['id', 'father_id', 'title', 'text', 'memo', 'updated_at']; - $meeting_images_select = ['image']; - $father_select = ['image', 'company']; - $meeting_approvals_select = ['approval_at']; + $meeting_select = ['id', 'title', 'text', 'updated_at']; + $child_select = ['image']; + $meeting_approvals_select = ['child_id', '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]['approval'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l->id)->orderBy('approval_at', 'desc')->get())) { + return ['status_code' => 400]; + } + + foreach ($result[$i]['approval'] as $j => $k) { + if (null === ($result[$i]['approval'][$j]['child'] = Child::select($child_select)->where('id', $k->child_id)->first())) { + return ['status_code' => 400]; + } + } + } + + return ['status_code' => 200, 'params' => $result]; } public function listOfApprovalOfChild (Request $r) { @@ -94,23 +136,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) { @@ -125,23 +174,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) { @@ -155,26 +211,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(); - $result[$i]['total'] = MeetingApprovals::where('meeting_id', $l['id'])->count(); - 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) { @@ -188,26 +245,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(); - $result[$i]['total'] = MeetingApprovals::where('meeting_id', $l['id'])->count(); - 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) { @@ -221,21 +280,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) { @@ -249,21 +311,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) { @@ -277,18 +342,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) { @@ -302,18 +370,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) { @@ -328,22 +399,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(); - $result[$i]['total'] = MeetingApprovals::where('meeting_id', $l['id'])->count(); - 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) { @@ -358,27 +434,31 @@ 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(); - $result[$i]['total'] = MeetingApprovals::where('meeting_id', $l['id'])->count(); - - 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) { - if (!isset($r->father_id)) { + if (!isset($meeting_id)) { return ['status_code' => 400]; } @@ -389,41 +469,71 @@ 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]['approval'] = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', $l->id)->whereNotNull('approval_at')->get())) { + return ['status_code' => 400]; + } + + foreach ($result[$i]['approval'] as $ii => $ra) { + if (null === ($result[$i]['approval'][$ii]['child'] = Child::select($child_select)->where('id', $ra->child_id)->first())) { + return ['status_code' => 400]; + } + } + } + + return ['status_code' => 200, 'params' => $result]; + } + + public function update (Request $r, $meeting_id) { + if (!isset($meeting_id)) { + return ['status_code' => 400, 'error_messages' => ['ミーティングの登録に失敗しました。']]; + } + + $validate = Validator::make($r->all(), [ + 'title' => 'required|max:100', + 'text' => 'required|max:2000', + 'memo' => 'max:2000', + 'pdf' => 'mimes:pdf' + ]); + + if ($validate->fails()) { + return ['status_code' => 422, 'error_messages' => $validate->errors()]; + } + + $update = [ + 'title' => $r->title, + 'text' => $r->text, + ]; + + if (isset($r->memo)) $update['memo'] = $r->memo; + if (isset($r->pdf)) $update['pdf'] = $r->pdf; + + try { + Meetings::where('meeting_id', $meeting_id)->update($update); + } catch (\Throwable $e) { + Log::critical($e->getMessage()); + return ['status_code' => 400]; + } + + return ['status_code' => 200]; } 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]; - } - - public function deleteRelationFather ($father_id) { - // 削除成功 - if (Meetings::where('father_id', $father_id)->delete()) { - return ['status_code' => 200]; - } - - // 削除失敗 - return ['status_code' => 400]; + return ['status_code' => 200]; } } diff --git a/backend/app/Http/Controllers/Api/TelActivationsController.php b/backend/app/Http/Controllers/Api/TelActivationsController.php deleted file mode 100644 index b31d1735..00000000 --- a/backend/app/Http/Controllers/Api/TelActivationsController.php +++ /dev/null @@ -1,18 +0,0 @@ -delete()) return ['status_code' => 200]; - - // 削除失敗 - return ['status_code' => 400]; - } -} diff --git a/backend/app/Http/Kernel.php b/backend/app/Http/Kernel.php index 30020a50..78c1eb1c 100644 --- a/backend/app/Http/Kernel.php +++ b/backend/app/Http/Kernel.php @@ -54,6 +54,9 @@ class Kernel extends HttpKernel */ protected $routeMiddleware = [ 'auth' => \App\Http\Middleware\Authenticate::class, + 'auth.admins' => \App\Http\Middleware\AuthAdmin::class, + 'auth.children' => \App\Http\Middleware\AuthChild::class, + 'auth.fathers' => \App\Http\Middleware\AuthFather::class, 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, 'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class, 'can' => \Illuminate\Auth\Middleware\Authorize::class, diff --git a/backend/app/Http/Middleware/AuthAdmin.php b/backend/app/Http/Middleware/AuthAdmin.php new file mode 100644 index 00000000..f7f39744 --- /dev/null +++ b/backend/app/Http/Middleware/AuthAdmin.php @@ -0,0 +1,29 @@ +expectsJson()) { + return route('adminlogin'); + } + } + + public function handle ($request, Closure $next, $guard = null) { + if (Auth::guard($guard)->check()) { + return redirect()->intended('/home'); + } + + return $next($request); +} +} diff --git a/backend/app/Http/Middleware/AuthChild.php b/backend/app/Http/Middleware/AuthChild.php new file mode 100644 index 00000000..d62b4046 --- /dev/null +++ b/backend/app/Http/Middleware/AuthChild.php @@ -0,0 +1,21 @@ +expectsJson()) { + return route('childrenlogin'); + } + } +} diff --git a/backend/app/Http/Middleware/AuthFather.php b/backend/app/Http/Middleware/AuthFather.php new file mode 100644 index 00000000..af9947b3 --- /dev/null +++ b/backend/app/Http/Middleware/AuthFather.php @@ -0,0 +1,21 @@ +expectsJson()) { + return route('fatherlogin'); + } + } +} diff --git a/backend/config/auth.php b/backend/config/auth.php index ba1a4d8c..c49a4b65 100644 --- a/backend/config/auth.php +++ b/backend/config/auth.php @@ -14,8 +14,8 @@ return [ */ 'defaults' => [ - 'guard' => 'web', - 'passwords' => 'users', + 'guard' => 'fathers', + 'passwords' => 'fathers', ], /* @@ -36,9 +36,17 @@ return [ */ 'guards' => [ - 'web' => [ + 'admins' => [ 'driver' => 'session', - 'provider' => 'users', + 'provider' => 'admins', + ], + 'fathers' => [ + 'driver' => 'session', + 'provider' => 'fathers', + ], + 'children' => [ + 'driver' => 'session', + 'provider' => 'children', ], 'api' => [ @@ -66,6 +74,18 @@ return [ */ 'providers' => [ + 'admins' => [ + 'driver' => 'eloquent', + 'model' => App\Models\Admin::class, + ], + 'fathers' => [ + 'driver' => 'eloquent', + 'model' => App\Models\Father::class, + ], + 'children' => [ + 'driver' => 'eloquent', + 'model' => App\Models\Child::class, + ], 'users' => [ 'driver' => 'eloquent', 'model' => App\Models\User::class, diff --git a/backend/database/factories/AdminFactory.php b/backend/database/factories/AdminFactory.php index d2b89b4d..738dbfbb 100644 --- a/backend/database/factories/AdminFactory.php +++ b/backend/database/factories/AdminFactory.php @@ -3,6 +3,7 @@ namespace Database\Factories; use \App\Models\Admin; +use Illuminate\Support\Facades\Hash; use Illuminate\Database\Eloquent\Factories\Factory; class AdminFactory extends Factory @@ -23,7 +24,7 @@ class AdminFactory extends Factory { return [ 'email' => $this->faker->email, - 'password' => $this->faker->password, + 'password' => Hash::make('password'), 'created_at' => $this->faker->dateTime, 'updated_at' => $this->faker->dateTime, ]; diff --git a/backend/database/factories/ChildFactory.php b/backend/database/factories/ChildFactory.php index 67cd72ac..f4316a42 100644 --- a/backend/database/factories/ChildFactory.php +++ b/backend/database/factories/ChildFactory.php @@ -3,6 +3,7 @@ namespace Database\Factories; use App\Models\Child; +use Illuminate\Support\Facades\Hash; use Illuminate\Database\Eloquent\Factories\Factory; class ChildFactory extends Factory @@ -31,8 +32,7 @@ class ChildFactory extends Factory 'identity' => $this->faker->text(20), 'email' => $this->faker->email, 'tel' => $tel[rand(0, 2)], - 'tel_verified_at' => $this->faker->dateTime, - 'password' => $this->faker->password, + 'password' => Hash::make('password'), 'last_name' => $this->faker->lastName, 'first_name' => $this->faker->firstName, 'image' => $this->faker->imageUrl, diff --git a/backend/database/factories/FatherFactory.php b/backend/database/factories/FatherFactory.php index f645ffe1..9cf4e1aa 100644 --- a/backend/database/factories/FatherFactory.php +++ b/backend/database/factories/FatherFactory.php @@ -3,6 +3,7 @@ namespace Database\Factories; use App\Models\Father; +use Illuminate\Support\Facades\Hash; use Illuminate\Database\Eloquent\Factories\Factory; class FatherFactory extends Factory @@ -29,8 +30,7 @@ class FatherFactory extends Factory return [ 'email' => $this->faker->email, - 'email_verified_at' => $this->faker->dateTime, - 'password' => $this->faker->password, + 'password' => Hash::make('password'), 'company' => $this->faker->company, 'image' => $this->faker->imageUrl, 'profile' => $this->faker->realText(49), diff --git a/backend/database/migrations/2021_08_12_054526_create_fathers_table.php b/backend/database/migrations/2021_08_12_054526_create_fathers_table.php index ecbc9322..86839a06 100644 --- a/backend/database/migrations/2021_08_12_054526_create_fathers_table.php +++ b/backend/database/migrations/2021_08_12_054526_create_fathers_table.php @@ -16,9 +16,8 @@ class CreateFathersTable extends Migration Schema::create('fathers', function (Blueprint $table) { $table->id(); $table->string('email', 255)->unique(); - $table->dateTime('email_verified_at'); $table->string('password', 72); - $table->string('company', 100)->nullable(); + $table->string('company', 100); $table->string('image', 100)->nullable(); $table->string('profile', 1000)->nullable(); $table->string('tel', 11)->unique(); diff --git a/backend/database/migrations/2021_08_13_042143_create_children_table.php b/backend/database/migrations/2021_08_13_042143_create_children_table.php index 63d153b5..dc2699cf 100644 --- a/backend/database/migrations/2021_08_13_042143_create_children_table.php +++ b/backend/database/migrations/2021_08_13_042143_create_children_table.php @@ -18,7 +18,6 @@ class CreateChildrenTable extends Migration $table->string('identity', 20); $table->string('email', 72)->unique(); $table->string('tel', 11)->unique(); - $table->dateTime('tel_verified_at'); $table->string('password', 255); $table->string('last_name', 100); $table->string('first_name', 100); diff --git a/backend/database/seeders/AdminsTableSeeder.php b/backend/database/seeders/AdminsTableSeeder.php index f7f44217..d140b15b 100644 --- a/backend/database/seeders/AdminsTableSeeder.php +++ b/backend/database/seeders/AdminsTableSeeder.php @@ -15,5 +15,6 @@ class AdminsTableSeeder extends Seeder public function run() { \App\Models\Admin::factory()->count(10)->create(); + \App\Models\Admin::create(['email' => 'chankan77@gmail.com', 'password' => 'password']); } } diff --git a/backend/routes/api.php b/backend/routes/api.php index 54ce64e4..96d5f859 100644 --- a/backend/routes/api.php +++ b/backend/routes/api.php @@ -14,81 +14,125 @@ use Illuminate\Support\Facades\Route; | */ -// FathersController -// Route::post('/fathers/login/', '\App\Http\Controllers\Api\FathersController@login'); -// Route::post('/fathers/registerTemporary/', '\App\Http\Controllers\Api\FathersController@registerTemporary'); -// Route::post('/fathers/registerMain/', '\App\Http\Controllers\Api\FathersController@registerMain'); -Route::get('/fathers/list/', '\App\Http\Controllers\Api\FathersController@list'); -Route::get('/fathers/listOfChild/', '\App\Http\Controllers\Api\FathersController@listOfChild'); -Route::get('/fathers/detail/{father_id}', '\App\Http\Controllers\Api\FathersController@detail'); -// Route::put('/fathers/updateImage/{father_id}', '\App\Http\Controllers\Api\FathersController@updateImage'); -// Route::put('/fathers/updateProfile/{father_id}', '\App\Http\Controllers\Api\FathersController@updateProfile'); -// Route::put('/fathers/updatePassword/{father_id}', '\App\Http\Controllers\Api\FathersController@updatePassword'); -Route::delete('/fathers/delete/{father_id}', '\App\Http\Controllers\Api\FathersController@delete'); -// Route::post('/fathers/checkEmail/', '\App\Http\Controllers\Api\FathersController@checkEmail'); - -// EmailActivationsController -Route::delete('/email-activations/deleteRelationOfFather/', '\App\Http\Controllers\Api\EmailActivationsController@deleteRelationOfFather'); - -// TelActivationsController -Route::delete('/tel-activations/deleteRelationOfChild/', '\App\Http\Controllers\Api\TelActivationsController@deleteRelationOfChild'); - -// MeetingsController -Route::post('/meetings/register/', '\App\Http\Controllers\Api\MeetingsController@register'); -Route::post('/meetings/registerFavorite/', '\App\Http\Controllers\Api\MeetingsController@registerFavorite'); -Route::get('/meetings/list/', '\App\Http\Controllers\Api\MeetingsController@list'); -Route::get('/meetings/listOfApprovalOfChild/', '\App\Http\Controllers\Api\MeetingsController@listOfApprovalOfChild'); -Route::get('/meetings/listOfNonApprovalOfChild/', '\App\Http\Controllers\Api\MeetingsController@listOfNonApprovalOfChild'); -Route::get('/meetings/listOfCompleteOfFather/', '\App\Http\Controllers\Api\MeetingsController@listOfCompleteOfFather'); -Route::get('/meetings/listOfIncompleteOfFather/', '\App\Http\Controllers\Api\MeetingsController@listOfIncompleteOfFather'); -Route::get('/meetings/listOfFavoriteOfFather/', '\App\Http\Controllers\Api\MeetingsController@listOfFavoriteOfFather'); -Route::get('/meetings/listOfNonFavoriteOfFather/', '\App\Http\Controllers\Api\MeetingsController@listOfNonFavoriteOfFather'); -Route::get('/meetings/searchOfApprovalOfChild/', '\App\Http\Controllers\Api\MeetingsController@searchOfApprovalOfChild'); -Route::get('/meetings/searchOfNonApprovalOfChild/', '\App\Http\Controllers\Api\MeetingsController@searchOfNonApprovalOfChild'); -Route::get('/meetings/searchOfCompleteOfFather/', '\App\Http\Controllers\Api\MeetingsController@searchOfCompleteOfFather'); -Route::get('/meetings/searchOfIncompleteOfFather/', '\App\Http\Controllers\Api\MeetingsController@searchOfIncompleteOfFather'); -Route::get('/meetings/detail/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@detail'); -Route::delete('/meetings/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@delete'); -Route::delete('/meetings/deleteRelationFather/{father_id}', '\App\Http\Controllers\Api\MeetingsController@deleteRelationFather'); - -// MeetingImagesController -Route::post('/meeting-images/register/', '\App\Http\Controllers\Api\MeetingImagesController@register'); -Route::delete('/meeting-images/deleteRelationMeeting/{meeting_id}', '\App\Http\Controllers\Api\MeetingImagesController@deleteRelationMeeting'); - -// MeetingApprovalsController -// Route::post('/meeting-approvals/register/', '\App\Http\Controllers\Api\MeetingApprovalsController@register'); -// Route::post('/meeting-approvals/registerOfApproval/', '\App\Http\Controllers\Api\MeetingApprovalsController@registerOfApproval'); -// Route::post('/meeting-approvals/listChildrenOfMeeting/', '\App\Http\Controllers\Api\MeetingApprovalsController@listChildrenOfMeeting'); -Route::get('/meeting-approvals/listChildrenOfApprovel/', '\App\Http\Controllers\Api\MeetingApprovalsController@listChildrenOfApprovel'); -Route::get('/meeting-approvals/listChildrenOfUnapprovel/', '\App\Http\Controllers\Api\MeetingApprovalsController@listChildrenOfUnapprovel'); -Route::delete('/meeting-approvals/deleteRelationMeeting/{meeting_id}', '\App\Http\Controllers\Api\MeetingApprovalsController@deleteRelationMeeting'); -Route::delete('/meeting-approvals/deleteRelationChild/{child_id}', '\App\Http\Controllers\Api\MeetingApprovalsController@deleteRelationChild'); - -// ChildrenController -// Route::post('/children/login/', '\App\Http\Controllers\Api\ChildrenController@login'); -// Route::post('/children/registerTemporary/', '\App\Http\Controllers\Api\ChildrenController@registerTemporary'); -// Route::post('/children/registerMain/', '\App\Http\Controllers\Api\ChildrenController@registerMain'); -// Route::post('/children/checkTel/', '\App\Http\Controllers\Api\ChildrenController@checkTel'); -Route::get('/children/list/', '\App\Http\Controllers\Api\ChildrenController@list'); -Route::get('/children/listOfFather/', '\App\Http\Controllers\Api\ChildrenController@listOfFather'); -Route::get('/children/listOfMeeting/', '\App\Http\Controllers\Api\ChildrenController@listOfMeeting'); -// Route::post('/children/listOfMeetingNotifyUnapprovel/', '\App\Http\Controllers\Api\ChildrenController@listOfMeetingNotifyUnapprovel'); -// Route::post('/children/listOfMeetingNotifyApprovel/', '\App\Http\Controllers\Api\ChildrenController@listOfMeetingNotifyApprovel'); -Route::get('/children/detail/{child_id}', '\App\Http\Controllers\Api\ChildrenController@detail'); -// Route::put('/children/updateImage/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updateImage'); -// Route::put('/children/updateProfile/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updateProfile'); -// Route::put('/children/updatePassword/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updatePassword'); -Route::delete('/children/delete/{child_id}', '\App\Http\Controllers\Api\ChildrenController@delete'); - -// FatherRelationsController -Route::post('/father-relations/register/', '\App\Http\Controllers\Api\FatherRelationsController@register'); -Route::post('/father-relations/updateHireDate/{child_id}', '\App\Http\Controllers\Api\FatherRelationsController@updateHireDate'); -Route::delete('/father-relations/deleteRelationFather/{father_id}', '\App\Http\Controllers\Api\FatherRelationsController@deleteRelationFather'); -Route::delete('/father-relations/deleteRelationChild/{child_id}', '\App\Http\Controllers\Api\FatherRelationsController@deleteRelationChild'); - -// LoginLimitsController -Route::post('/login-limits/countFailure/', '\App\Http\Controllers\Api\LoginLimitsController@countFailure'); -Route::delete('/login-limits/delete/', '\App\Http\Controllers\Api\LoginLimitsController@delete'); +// AdminController +//// 不明 +Route::post('/admin/login', '\App\Http\Controllers\Api\AdminController@login')->name('adminlogin'); +Route::post('/admin/logout', '\App\Http\Controllers\Api\AdminController@logout')->middleware(['auth.admins:admins', 'throttle:10,10']); // ContactsController -Route::post('/contacts/register/', '\App\Http\Controllers\Api\ContactsController@register'); +//// 不明 +Route::post('/contacts/register', '\App\Http\Controllers\Api\ContactsController@register'); + +// FathersController +//// 不明 +Route::post('/fathers/registerMain/', '\App\Http\Controllers\Api\FathersController@registerMain')->name('fatherregistermain'); +Route::post('/fathers/requestPassword/', '\App\Http\Controllers\Api\FathersController@requestPassword')->name('fatherrequestpassword'); +// Route::post('/fathers/login/', '\App\Http\Controllers\Api\FathersController@login')->name('fatherlogin'); + +//// admin +Route::get('/admin/fathers/list/', '\App\Http\Controllers\Api\FathersController@list')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::put('/admin/fathers/search', '\App\Http\Controllers\Api\FathersController@search')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::put('/admin/fathers/updateImage/{father_id}', '\App\Http\Controllers\Api\FathersController@updateImage')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::put('/admin/fathers/updateProfile/{father_id}', '\App\Http\Controllers\Api\FathersController@updateProfile')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::put('/admin/fathers/updatePassword/{father_id}', '\App\Http\Controllers\Api\FathersController@updatePassword')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::post('/admin/fathers/detail/{father_id}', '\App\Http\Controllers\Api\FathersController@detail')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::delete('/admin/fathers/delete/', '\App\Http\Controllers\Api\FathersController@withdrawal')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::post('/admin/fathers/registerTemporary/', '\App\Http\Controllers\Api\FathersController@registerTemporary')->middleware(['auth.admins:admins', 'throttle:10,10']); + +//// fathers +Route::put('/fathers/updateImage/{father_id}', '\App\Http\Controllers\Api\FathersController@updateImage')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::put('/fathers/updateProfile/{father_id}', '\App\Http\Controllers\Api\FathersController@updateProfile')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::put('/fathers/updatePassword/{father_id}', '\App\Http\Controllers\Api\FathersController@updatePassword')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::delete('/fathers/withdrawal/', '\App\Http\Controllers\Api\FathersController@withdrawal')->middleware(['auth.fathers:fathers', 'throttle:10,10']); + +//// children +Route::get('/children/fathers/listOfChild/', '\App\Http\Controllers\Api\FathersController@listOfChild')->middleware(['auth.children:children', 'throttle:10,10']); +Route::get('/children/fathers/detail/{father_id}', '\App\Http\Controllers\Api\FathersController@detail')->middleware(['auth.children:children', 'throttle:10,10']); + +// ChildrenController +//// 不明 +Route::post('/children/registerTemporary/', '\App\Http\Controllers\Api\ChildrenController@registerTemporary')->name('childrenregistertemporary'); +Route::post('/children/registerMain/', '\App\Http\Controllers\Api\ChildrenController@registerMain')->name('childrenregistermain'); +// Route::post('/children/requestPassword/', '\App\Http\Controllers\Api\ChildrenController@requestPassword')->name('childrenrequestpassword'); +// Route::post('/children/login/', '\App\Http\Controllers\Api\ChildrenController@login')->name('childrenlogin'); + +//// admin +Route::get('/admin/children/list', '\App\Http\Controllers\Api\ChildrenController@list')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::post('/admin/children/search', '\App\Http\Controllers\Api\ChildrenController@search')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::put('/admin/children/updateProfile/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updateProfile')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::put('/admin/children/updateImage/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updateImage')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::put('/admin/children/updatePassword/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updatePassword')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::get('/admin/children/detail/{child_id}', '\App\Http\Controllers\Api\ChildrenController@detail')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::delete('/admin/children/delete/{child_id}', '\App\Http\Controllers\Api\ChildrenController@withdrawal')->middleware(['auth.admins:admins', 'throttle:10,10']); + +//// fathers +Route::get('/fathers/children/listOfFather/', '\App\Http\Controllers\Api\ChildrenController@listOfFather')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::get('/fathers/children/listOfMeeting/', '\App\Http\Controllers\Api\ChildrenController@listOfMeeting')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::post('/fathers/children/listOfMeetingNotifyUnapprovel/', '\App\Http\Controllers\Api\ChildrenController@listOfMeetingNotifyUnapprovel')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::post('/fathers/children/listOfMeetingNotifyApprovel/', '\App\Http\Controllers\Api\ChildrenController@listOfMeetingNotifyApprovel')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::get('/fathers/children/detail/{child_id}', '\App\Http\Controllers\Api\ChildrenController@detail')->middleware(['auth.fathers:fathers', 'throttle:10,10']); + +//// children +Route::get('/children/detail/{child_id}', '\App\Http\Controllers\Api\ChildrenController@detail')->middleware(['auth.children:children', 'throttle:10,10']); +Route::put('/children/updateImage/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updateImage')->middleware(['auth.children:children', 'throttle:10,10']); +Route::put('/children/updateProfile/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updateProfile')->middleware(['auth.children:children', 'throttle:10,10']); +Route::put('/children/updatePassword/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updatePassword')->middleware(['auth.children:children', 'throttle:10,10']); +Route::delete('/children/withdrawal/', '\App\Http\Controllers\Api\ChildrenController@withdrawal')->middleware(['auth.children:children', 'throttle:10,10']); + +// MeetingsController +//// admin +Route::get('/admin/meetings/list', '\App\Http\Controllers\Api\MeetingsController@list')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::post('/admin/meetings/search', '\App\Http\Controllers\Api\MeetingsController@search')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::get('/admin/meetings/detail/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@detail')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::put('/admin/meetings/update/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@update')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::delete('/admin/meetings/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@delete')->middleware(['auth.admins:admins', 'throttle:10,10']); + +//// fathers +Route::post('/fathers/meetings/register/', '\App\Http\Controllers\Api\MeetingsController@register')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::post('/fathers/meetings/registerFavorite/', '\App\Http\Controllers\Api\MeetingsController@registerFavorite')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::get('/fathers/meetings/listOfCompleteOfFather/', '\App\Http\Controllers\Api\MeetingsController@listOfCompleteOfFather')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::get('/fathers/meetings/listOfIncompleteOfFather/', '\App\Http\Controllers\Api\MeetingsController@listOfIncompleteOfFather')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::get('/fathers/meetings/listOfFavoriteOfFather/', '\App\Http\Controllers\Api\MeetingsController@listOfFavoriteOfFather')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::get('/fathers/meetings/listOfNonFavoriteOfFather/', '\App\Http\Controllers\Api\MeetingsController@listOfNonFavoriteOfFather')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::get('/fathers/meetings/searchOfCompleteOfFather/', '\App\Http\Controllers\Api\MeetingsController@searchOfCompleteOfFather')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::get('/fathers/meetings/searchOfIncompleteOfFather/', '\App\Http\Controllers\Api\MeetingsController@searchOfIncompleteOfFather')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::get('/fathers/meetings/detail/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@detail')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::put('/fathers/meetings/update/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@update')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::delete('/fathers/meetings/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@delete')->middleware(['auth.fathers:fathers', 'throttle:10,10']); + +//// children +Route::get('/children/meetings/listOfApprovalOfChild/', '\App\Http\Controllers\Api\MeetingsController@listOfApprovalOfChild')->middleware(['auth.children:children', 'throttle:10,10']); +Route::get('/children/meetings/listOfNonApprovalOfChild/', '\App\Http\Controllers\Api\MeetingsController@listOfNonApprovalOfChild')->middleware(['auth.children:children', 'throttle:10,10']); +Route::get('/children/meetings/searchOfApprovalOfChild/', '\App\Http\Controllers\Api\MeetingsController@searchOfApprovalOfChild')->middleware(['auth.children:children', 'throttle:10,10']); +Route::get('/children/meetings/searchOfNonApprovalOfChild/', '\App\Http\Controllers\Api\MeetingsController@searchOfNonApprovalOfChild')->middleware(['auth.children:children', 'throttle:10,10']); +Route::get('/children/meetings/detail/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@detail')->middleware(['auth.children:children', 'throttle:10,10']); + +// MeetingImagesController +//// admin +Route::post('/admin/meeting/images/register/', '\App\Http\Controllers\Api\MeetingImagesController@register')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::delete('/admin/meeting/images/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingImagesController@delete')->middleware(['auth.admins:admins', 'throttle:10,10']); + +//// fathers +Route::post('/fathers/meeting/images/register/', '\App\Http\Controllers\Api\MeetingImagesController@register')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::delete('/fathers/meeting/images/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingImagesController@delete')->middleware(['auth.fathers:fathers', 'throttle:10,10']); + +// MeetingApprovalsController +//// admin +Route::post('/admin/meeting/approvals/register/', '\App\Http\Controllers\Api\MeetingApprovalsController@register')->middleware(['auth.admins:admins', 'throttle:10,10']); +Route::delete('/admin/meeting/approvals/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingApprovalsController@delete')->middleware(['auth.admins:admins', 'throttle:10,10']); + +//// fathers +// Route::post('/fathers/meeting/approvals/register/{meeting_id}', '\App\Http\Controllers\Api\MeetingApprovalsController@register')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +// Route::delete('/fathers/meeting/approvals/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingApprovalsController@delete')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::post('/fathers/meeting/approvals/listChildrenOfMeeting/', '\App\Http\Controllers\Api\MeetingApprovalsController@listChildrenOfMeeting')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::get('/fathers/meeting/approvals/listChildrenOfApprovel/', '\App\Http\Controllers\Api\MeetingApprovalsController@listChildrenOfApprovel')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::get('/fathers/meeting/approvals/listChildrenOfUnapprovel/', '\App\Http\Controllers\Api\MeetingApprovalsController@listChildrenOfUnapprovel')->middleware(['auth.fathers:fathers', 'throttle:10,10']); + +//// children +Route::post('/children/meeting/approvals/registerApproval/', '\App\Http\Controllers\Api\MeetingApprovalsController@registerApproval')->middleware(['auth.children:children', 'throttle:10,10']); + +// FatherRelationsController +//// fathers +Route::post('/fathers/father/relations/register', '\App\Http\Controllers\Api\FatherRelationsController@register')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::put('/fathers/father/relations/updateHireDate/{child_id}', '\App\Http\Controllers\Api\FatherRelationsController@updateHireDate')->middleware(['auth.fathers:fathers', 'throttle:10,10']); +Route::delete('/fathers/father/relations/deleteRelationChild/{child_id}', '\App\Http\Controllers\Api\FatherRelationsController@deleteRelationChild')->middleware(['auth.fathers:fathers', 'throttle:10,10']);