APIの変更です。

このコミットが含まれているのは:
守矢諏訪子 2021-10-06 14:50:13 +09:00
コミット e780a6a912
11個のファイルの変更550行の追加393行の削除

ファイルの表示

@ -10,92 +10,209 @@ use App\Models\FatherRelation;
use App\Models\MeetingApprovals;
class ChildrenController extends Controller {
public function login () {}
public function login () {}
public function registerTemporary () {}
public function registerTemporary () {}
public function registerMain () {}
public function requestPassword () {}
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'];
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];
}
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 list () {
// 親一覧の取得に成功
if ($result = Child::orderBy('created_at', 'desc')->get()->toArray()) {
return ['status_code' => 200, 'params' => $result];
}
}
return ['status_code' => 200, 'params' => $result];
// 親一覧の取得に失敗
return ['status_code' => 400];
}
// 親詳細の取得に失敗
return ['status_code' => 400];
}
public function listOfFather (Request $r) {
$result = [];
$child_select = ['id', 'image', 'last_name', 'first_name'];
public function updateImage ($child_id) {}
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']);
}
public function updateProfile ($child_id) {}
return ['status_code' => 200, 'params' => $result];
}
public function updatePassword ($child_id) {}
public function delete ($child_id) {
// 削除成功
if (Child::where('id', $child_id)->delete()) {
return ['status_code' => 200];
return ['status_code' => 400];
}
// 削除失敗
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 (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 ($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];
}
return ['status_code' => 400];
}
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 ($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];
}
return ['status_code' => 400];
}
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();
}
}
return ['status_code' => 200, 'params' => $result];
}
// 親詳細の取得に失敗
return ['status_code' => 400];
}
public function updateImage (Request $r, $child_id) {
if (!isset($r->image) || !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($r->image) || !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) {
// 削除成功
if (Child::where('id', $child_id)->delete()) {
return ['status_code' => 200];
}
// 削除失敗
return ['status_code' => 400];
}
}

ファイルの表示

@ -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' => ['お問い合わせの送信に失敗しました。']];
}
// 成功

ファイルの表示

@ -1,19 +0,0 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\EmailActivation;
class EmailActivationsController extends Controller {
public function deleteRelationFather ($father_id) {
// 削除成功
if (EmailActivation::where('father_id', $father_id)->delete()) {
return ['status_code' => 200];
}
// 削除失敗
return ['status_code' => 400];
}
}

ファイルの表示

@ -8,55 +8,21 @@ use Illuminate\Http\Request;
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' => ['子の入社日の更新に成功しました。']];
}
}

ファイルの表示

@ -9,77 +9,165 @@ use App\Models\Father;
use App\Models\FatherRelation;
class FathersController extends Controller {
public function login () {}
public function login () {}
public function registerTemporary () {}
public function registerTemporary () {}
public function registerMain () {}
public function registerMain () {}
public function list () {
$result = [];
$father_select = ['id', 'company', 'image'];
$father_relation_select = ['created_at'];
public function list () {
$result = [];
$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();
}
// 親一覧の取得に成功
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];
return ['status_code' => 200, 'params' => $result];
}
// 親一覧の取得に失敗
return ['status_code' => 400];
}
// 親一覧の取得に失敗
return ['status_code' => 400];
}
public function listOfChild (Request $r) {
$result = [];
$father_select = ['id', 'company', 'image'];
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 = [];
// 親一覧の取得に成功
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']);
}
foreach ($list as $l) {
$result[] = Father::select($father_select)->find($l['father_id']);
}
return ['status_code' => 200, 'params' => $result];
}
return ['status_code' => 200, 'params' => $result];
// 親一覧の取得に失敗
return ['status_code' => 400];
}
// 親一覧の取得に失敗
return ['status_code' => 400];
}
public function detail ($father_id) {
$father_select = ['id', 'email', 'company', 'image', 'tel'];
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 ($result = Father::select($father_select)->where('id', $father_id)->orderBy('created_at', 'desc')->get()->toArray()) {
return ['status_code' => 200, 'params' => $result];
// 親詳細の取得に失敗
return ['status_code' => 400];
}
// 親詳細の取得に失敗
return ['status_code' => 400];
}
public function updateImage (Request $r, $father_id) {
if (!isset($r->image) || !isset($father_id)) {
return ['status_code' => 400, 'error_messages' => 'アップロードに失敗しました。'];
}
public function updateImage ($father_id) {}
// バリデーションエラー
$validate = Validator::make($r->all(), ['image' => 'max:1024|mimes:jpg,png,gif']);
// 300x300px
public function updateProfile ($father_id) {}
if ($validate->fails()) {
return ['status_code' => 422, 'error_messages' => $validate->errors()];
}
public function updatePassword ($father_id) {}
try {
Father::where('id', $father_id)->update($r->all());
} catch (\Throwable $e) {
// 親プロフィール画像のアップロードに失敗
Log::critical($e->getMessage());
return ['status_code' => 400, 'error_messages' => ['アップロードに失敗しました。']];
}
public function delete ($father_id) {
// 削除成功
if (Father::where('id', $father_id)->delete()) {
return ['status_code' => 200];
// 親プロフィール画像のアップロードに成功
return ['status_code' => 200, 'success_messages' => ['アップロードに成功しました。']];
}
// 削除失敗
return ['status_code' => 400];
}
public function updateProfile (Request $r, $father_id) {
if (!isset($father_id)) {
return ['status_code' => 400, 'error_messages' => 'プロフィールの更新に失敗しました。'];
}
public function checkEmail () {}
// バリデーションエラー
$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) {
// 成功
if (Father::where('id', $father_id)->delete()) {
return ['status_code' => 200, 'success_messages' => ['親の削除に成功しました。']];
}
// 失敗
return ['status_code' => 400, 'error_messages' => ['親の削除に失敗しました。']];
}
public function delete ($meeting_id) {
// 成功
if (Meeting::where('id', $meeting_id)->delete()) {
return ['status_code' => 200, 'success_messages' => ['ミーティングを削除に成功しました。']];
}
// 失敗
return ['status_code' => 400, 'error_messages' => ['ミーティングの削除に失敗しました。']];
}
}

ファイルの表示

@ -1,46 +0,0 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\LoginLimits;
class LoginLimitsController extends Controller {
public function countFailure (Request $r) {
// user_agentがなければ、エラーを出します。
if (!isset($r->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];
}
}

ファイルの表示

@ -10,65 +10,109 @@ use App\Models\Meeting;
use App\Models\MeetingApprovals;
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];
}
// 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];
}
}
public function deleteRelationChild ($child_id) {
// 削除成功
if (MeetingApprovals::where('child_id', $child_id)->delete()) return ['status_code' => 200];
return ['status' => 200, 'params' => $params];
}
// 削除失敗
return ['status_code' => 400];
}
// エラーの場合
return ['status' => 400];
}
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'];
// 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];
}
// エラーの場合
return ['status' => 400];
}
public function deleteRelationMeeting ($meeting_id) {
if (!isset($meeting_id)) {
return ['status_code' => 400];
}
// 削除成功
if (MeetingApprovals::where('meeting_id', $meeting_id)->delete()) {
return ['status_code' => 200];
}
// 削除失敗
return ['status_code' => 400];
}
public function deleteRelationChild ($child_id) {
if (!isset($child_id)) {
return ['status_code' => 400];
}
// 削除成功
if (MeetingApprovals::where('child_id', $child_id)->delete()) {
return ['status_code' => 200];
}
// 削除失敗
return ['status_code' => 400];
}
}

ファイルの表示

@ -10,6 +10,10 @@ 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,16 +28,30 @@ 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];
}
}
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()) {

ファイルの表示

@ -15,33 +15,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) {
@ -413,14 +417,4 @@ class MeetingsController extends Controller {
// 削除失敗
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];
}
}

ファイルの表示

@ -1,18 +0,0 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\TelActivation;
class TelActivationsController extends Controller {
public function deleteRelationChild ($child_id) {
// 削除成功
if (TelActivation::where('child_id', $child_id)->delete()) return ['status_code' => 200];
// 削除失敗
return ['status_code' => 400];
}
}

ファイルの表示

@ -14,81 +14,94 @@ use Illuminate\Support\Facades\Route;
|
*/
// ContactsController
//// 不明
Route::post('/contacts/register/', '\App\Http\Controllers\Api\ContactsController@register');
// 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');
// Route::post('/fathers/login/', '\App\Http\Controllers\Api\FathersController@login');
// EmailActivationsController
Route::delete('/email-activations/deleteRelationOfFather/', '\App\Http\Controllers\Api\EmailActivationsController@deleteRelationOfFather');
//// admin
Route::get('/admin/fathers/list/', '\App\Http\Controllers\Api\FathersController@list');
Route::delete('/admin/fathers/delete/{father_id}', '\App\Http\Controllers\Api\FathersController@delete');
// Route::post('/admin/fathers/registerTemporary/', '\App\Http\Controllers\Api\FathersController@registerTemporary');
// TelActivationsController
Route::delete('/tel-activations/deleteRelationOfChild/', '\App\Http\Controllers\Api\TelActivationsController@deleteRelationOfChild');
//// fathers
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/withdrawal/', '\App\Http\Controllers\Api\FathersController@withdrawal');
// 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');
//// children
Route::get('/children/fathers/listOfChild/', '\App\Http\Controllers\Api\FathersController@listOfChild');
Route::get('/children/fathers/detail/{father_id}', '\App\Http\Controllers\Api\FathersController@detail');
// 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::post('/children/requestPassword/', '\App\Http\Controllers\Api\ChildrenController@requestPassword');
// Route::post('/children/login/', '\App\Http\Controllers\Api\ChildrenController@login');
//// fathers
Route::get('/fathers/children/listOfFather/', '\App\Http\Controllers\Api\ChildrenController@listOfFather');
Route::get('/fathers/children/listOfMeeting/', '\App\Http\Controllers\Api\ChildrenController@listOfMeeting');
Route::post('/fathers/children/listOfMeetingNotifyUnapprovel/', '\App\Http\Controllers\Api\ChildrenController@listOfMeetingNotifyUnapprovel');
Route::post('/fathers/children/listOfMeetingNotifyApprovel/', '\App\Http\Controllers\Api\ChildrenController@listOfMeetingNotifyApprovel');
Route::get('/fathers/children/detail/{child_id}', '\App\Http\Controllers\Api\ChildrenController@detail');
//// children
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');
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/withdrawal/', '\App\Http\Controllers\Api\ChildrenController@withdrawal');
// MeetingsController
//// admin
Route::get('/admin/meetings/list/', '\App\Http\Controllers\Api\MeetingsController@list');
Route::delete('/admin/meetings/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@delete');
//// fathers
Route::post('/fathers/meetings/register/', '\App\Http\Controllers\Api\MeetingsController@register');
Route::post('/fathers/meetings/registerFavorite/', '\App\Http\Controllers\Api\MeetingsController@registerFavorite');
Route::get('/fathers/meetings/listOfCompleteOfFather/', '\App\Http\Controllers\Api\MeetingsController@listOfCompleteOfFather');
Route::get('/fathers/meetings/listOfIncompleteOfFather/', '\App\Http\Controllers\Api\MeetingsController@listOfIncompleteOfFather');
Route::get('/fathers/meetings/listOfFavoriteOfFather/', '\App\Http\Controllers\Api\MeetingsController@listOfFavoriteOfFather');
Route::get('/fathers/meetings/listOfNonFavoriteOfFather/', '\App\Http\Controllers\Api\MeetingsController@listOfNonFavoriteOfFather');
Route::get('/fathers/meetings/searchOfCompleteOfFather/', '\App\Http\Controllers\Api\MeetingsController@searchOfCompleteOfFather');
Route::get('/fathers/meetings/searchOfIncompleteOfFather/', '\App\Http\Controllers\Api\MeetingsController@searchOfIncompleteOfFather');
Route::get('/fathers/meetings/detail/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@detail');
Route::delete('/fathers/meetings/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@delete');
//// children
Route::get('/children/meetings/listOfApprovalOfChild/', '\App\Http\Controllers\Api\MeetingsController@listOfApprovalOfChild');
Route::get('/children/meetings/listOfNonApprovalOfChild/', '\App\Http\Controllers\Api\MeetingsController@listOfNonApprovalOfChild');
Route::get('/children/meetings/searchOfApprovalOfChild/', '\App\Http\Controllers\Api\MeetingsController@searchOfApprovalOfChild');
Route::get('/children/meetings/searchOfNonApprovalOfChild/', '\App\Http\Controllers\Api\MeetingsController@searchOfNonApprovalOfChild');
Route::get('/children/meetings/detail/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@detail');
// MeetingImagesController
//// admin
Route::post('/admin/meeting-images/register/', '\App\Http\Controllers\Api\MeetingImagesController@register');
Route::delete('/admin/meeting-images/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingImagesController@delete');
//// fathers
Route::post('/fathers/meeting-images/register/', '\App\Http\Controllers\Api\MeetingImagesController@register');
Route::delete('/fathers/meeting-images/deleteRelationMeeting/{meeting_id}', '\App\Http\Controllers\Api\MeetingImagesController@deleteRelationMeeting');
// MeetingApprovalsController
//// fathers
Route::post('/fathers/meeting-approvals/listChildrenOfMeeting/', '\App\Http\Controllers\Api\MeetingApprovalsController@listChildrenOfMeeting');
Route::get('/fathers/meeting-approvals/listChildrenOfApprovel/', '\App\Http\Controllers\Api\MeetingApprovalsController@listChildrenOfApprovel');
Route::get('/fathers/meeting-approvals/listChildrenOfUnapprovel/', '\App\Http\Controllers\Api\MeetingApprovalsController@listChildrenOfUnapprovel');
//// children
Route::post('/children/meeting-approvals/registerOfApproval/', '\App\Http\Controllers\Api\MeetingApprovalsController@registerOfApproval');
// FatherRelationsController
Route::post('/father-relations/register/', '\App\Http\Controllers\Api\FatherRelationsController@register');
Route::put('/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');
// ContactsController
Route::post('/contacts/register/', '\App\Http\Controllers\Api\ContactsController@register');
//// fathers
Route::put('/fathers/father-relations/updateHireDate/{child_id}', '\App\Http\Controllers\Api\FatherRelationsController@updateHireDate');