親子画面:IDはセッションから受け取る。管理者画面:IDはリクエストから受け取る。

このコミットが含まれているのは:
守矢諏訪子 2022-01-02 14:29:47 +09:00
コミット 0ef4e2f2d7
5個のファイルの変更58行の追加53行の削除

ファイルの表示

@ -417,6 +417,7 @@ class ChildrenController extends Controller {
if (isset($r->child_id)) {
$child_id = $r->child_id;
}
$child_id = request()->route()->action['as'] == 'cia' ? (int)$child_id : (int)session()->get('children')['id'];
if (!isset($r->image) || !isset($child_id)) {
return ['status_code' => 400, 'error_messages' => ['画像の更新に失敗しました。']];
@ -493,6 +494,7 @@ class ChildrenController extends Controller {
if (isset($r->child_id)) {
$child_id = $r->child_id;
}
$child_id = request()->route()->action['as'] == 'cua' ? (int)$child_id : (int)session()->get('children')['id'];
if (!isset($child_id)) {
return ['status_code' => 400, 'error_messages' => ['子の更新に失敗しました。']];
@ -542,6 +544,7 @@ class ChildrenController extends Controller {
if (isset($r->child_id)) {
$child_id = $r->child_id;
}
$child_id = request()->route()->action['as'] == 'cpa' ? (int)$child_id : (int)session()->get('children')['id'];
if (is_null($child_id) && !isset($r->token)) {
return ['status_code' => 400, 'error_messages' => ['パスワードの更新に失敗しました。']];
@ -581,12 +584,14 @@ class ChildrenController extends Controller {
}
public function withdrawal (Request $r) {
$child_id = request()->route()->action['as'] == 'cwa' ? (int)$r->child_id : (int)session()->get('children')['id'];
// 削除成功
try {
// DBに入ります。
DB::beginTransaction();
$child = Child::find((int)$r->child_id);
$child = Child::find($child_id);
$img = $child->image;
$child->delete();

ファイルの表示

@ -556,14 +556,15 @@ class FathersController extends Controller {
public function withdrawal (Request $r) {
$images = [];
$pdfs = [];
$father_id = request()->route()->action['as'] == 'pwa' ? (int)$r->father_id : (int)session()->get('fathers')['id'];
try {
// DBに入ります。
DB::beginTransaction();
$father = Father::find((int)$r->father_id);
$rel = FatherRelation::where('father_id', (int)$r->father_id);
$meet = Meeting::where('father_id', (int)$r->father_id);
$father = Father::find($father_id);
$rel = FatherRelation::where('father_id', $father_id);
$meet = Meeting::where('father_id', $father_id);
if ($meet->count() > 0) {
foreach ($meet->get() as $n) {

ファイルの表示

@ -95,11 +95,11 @@ class MeetingApprovalsController extends Controller {
}
public function registerApproval (Request $r) {
if (!isset($r->meeting_id) || !isset($r->child_id)) {
if (!isset($r->meeting_id) || !isset(session()->get('children')['id'])) {
return ['status_code' => 400, 'error_messages' => ['承認に失敗しました。']];
}
if (null === (MeetingApprovals::where('meeting_id', (int)$r->meeting_id)->where('child_id', (int)$r->child_id)->first())) {
if (null === (MeetingApprovals::where('meeting_id', (int)$r->meeting_id)->where('child_id', (int)session()->get('children')['id'])->first())) {
return ['status_code' => 400, 'error_messages' => ['承認に失敗しました。']];
}
@ -115,7 +115,7 @@ class MeetingApprovalsController extends Controller {
$update = ['approval_at' => date('Y-m-d H:i:s')];
try {
MeetingApprovals::where('meeting_id', (int)$r->meeting_id)->where('child_id', (int)$r->child_id)->update($update);
MeetingApprovals::where('meeting_id', (int)$r->meeting_id)->where('child_id', (int)session()->get('children')['id'])->update($update);
Mail::to($father->email)->send(new MeetingEditAwareness(session()->get('children')['last_name'], session()->get('children')['first_name'], $r->meeting_id));
} catch (\Throwable $e) {
// 失敗
@ -135,7 +135,6 @@ class MeetingApprovalsController extends Controller {
$update = ['hire_at' => date('Y-m-d H:i:s', strtotime($r->hire_at))];
if (null === ($params = MeetingApprovals::select($meeting_approvals_select)->where('meeting_id', (int)$r->meeting_id)->where('child_id', (int)$r->child_id)->get())) {
return ['status_code' => 400, 'error_messages' => ['承認に失敗しました。']];
}

ファイルの表示

@ -21,7 +21,7 @@ use App\Mail\FathersApprovalMail;
class MeetingsController extends Controller {
public function register (Request $r) {
if (!isset($r->father_id)) {
if (!isset(session()->get('fathers')['id'])) {
return ['status_code' => 400, 'error_messages' => ['ミーティングの登録に失敗しました。']];
}
@ -76,7 +76,7 @@ class MeetingsController extends Controller {
}
$insert = [
'father_id' => $r->father_id,
'father_id' => (int)session()->get('fathers')['id'],
'title' => $r->title,
'text' => $r->text,
'memo' => $r->memo
@ -237,7 +237,7 @@ class MeetingsController extends Controller {
}
public function listOfApprovalOfChild (Request $r) {
if (!isset($r->child_id)) {
if (!isset(session()->get('children')['id'])) {
return ['status_code' => 400];
}
@ -248,14 +248,14 @@ class MeetingsController extends Controller {
$meeting_approvals_select = ['approval_at'];
// 取得に成功
if (null === ($approval = MeetingApprovals::select('meeting_id')->where('child_id', (int)$r->child_id)->whereNotNull('approval_at')->orderBy('updated_at', 'desc')->get())) {
if (null === ($approval = MeetingApprovals::select('meeting_id')->where('child_id', (int)session()->get('children')['id'])->whereNotNull('approval_at')->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
foreach ($approval as $a) {
if (null !== ($list = Meeting::select($meeting_select)->where('id', (int)$a->meeting_id)->get())) {
foreach ($list as $i => $l) {
if (null === ($fr = FatherRelation::select('id')->where('father_id', (int)$l->father_id)->where('child_id', (int)$r->child_id)->first())) {
if (null === ($fr = FatherRelation::select('id')->where('father_id', (int)$l->father_id)->where('child_id', (int)session()->get('children')['id'])->first())) {
continue;
}
if (null === ($l->father = Father::select($father_select)->where('id', (int)$l->father_id)->first())) {
@ -276,7 +276,7 @@ class MeetingsController extends Controller {
}
public function listOfNonApprovalOfChild (Request $r) {
if (!isset($r->child_id)) {
if (!isset(session()->get('children')['id'])) {
return ['status_code' => 400];
}
@ -287,14 +287,14 @@ class MeetingsController extends Controller {
$meeting_approvals_select = ['approval_at'];
// 取得に成功
if (null === ($approval = MeetingApprovals::select('meeting_id')->where('child_id', (int)$r->child_id)->whereNull('approval_at')->orderBy('updated_at', 'asc')->get())) {
if (null === ($approval = MeetingApprovals::select('meeting_id')->where('child_id', (int)session()->get('children')['id'])->whereNull('approval_at')->orderBy('updated_at', 'asc')->get())) {
return ['status_code' => 400];
}
foreach ($approval as $a) {
if (null !== ($list = Meeting::select($meeting_select)->where('id', (int)$a->meeting_id)->get())) {
foreach ($list as $i => $l) {
if (null === ($fr = FatherRelation::select('id')->where('father_id', (int)$l->father_id)->where('child_id', (int)$r->child_id)->first())) {
if (null === ($fr = FatherRelation::select('id')->where('father_id', (int)$l->father_id)->where('child_id', (int)session()->get('children')['id'])->first())) {
continue;
}
if (null === ($l->father = Father::select($father_select)->where('id', (int)$l->father_id)->first())) {
@ -315,7 +315,7 @@ class MeetingsController extends Controller {
}
public function listOfCompleteOfFather (Request $r) {
if (!isset($r->father_id)) {
if (!isset(session()->get('fathers')['id'])) {
return ['status_code' => 400];
}
@ -325,7 +325,7 @@ class MeetingsController extends Controller {
$child_select = ['image'];
// 取得に成功
if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)$r->father_id)->orderBy('updated_at', 'desc')->get())) {
if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)session()->get('fathers')['id'])->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
@ -362,7 +362,7 @@ class MeetingsController extends Controller {
}
public function listOfIncompleteOfFather (Request $r) {
if (!isset($r->father_id)) {
if (!isset(session()->get('fathers')['id'])) {
return ['status_code' => 400];
}
@ -372,7 +372,7 @@ class MeetingsController extends Controller {
$child_select = ['image'];
// 取得に成功
if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)$r->father_id)->orderBy('updated_at', 'desc')->get())) {
if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)session()->get('fathers')['id'])->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
@ -403,7 +403,7 @@ class MeetingsController extends Controller {
}
public function listOfFavoriteOfFather (Request $r) {
if (!isset($r->father_id)) {
if (!isset(session()->get('fathers')['id'])) {
return ['status_code' => 400];
}
@ -413,7 +413,7 @@ class MeetingsController extends Controller {
$child_select = ['image'];
// 取得に成功
if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)$r->father_id)->where('is_favorite', 1)->orderBy('updated_at', 'desc')->get())) {
if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)session()->get('fathers')['id'])->where('is_favorite', 1)->orderBy('updated_at', 'desc')->get())) {
return ['status_code' => 400];
}
@ -437,7 +437,7 @@ class MeetingsController extends Controller {
}
public function listOfNonFavoriteOfFather (Request $r) {
if (!isset($r->father_id)) {
if (!isset(session()->get('fathers')['id'])) {
return ['status_code' => 400];
}
@ -447,7 +447,7 @@ class MeetingsController extends Controller {
$child_select = ['image'];
// 取得に成功
if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)$r->father_id)->where('is_favorite', 0)->orderBy('created_at', 'desc')->get())) {
if (null === ($list = Meeting::select($meeting_select)->where('father_id', (int)session()->get('fathers')['id'])->where('is_favorite', 0)->orderBy('created_at', 'desc')->get())) {
return ['status_code' => 400];
}
@ -471,7 +471,7 @@ class MeetingsController extends Controller {
}
public function searchOfApprovalOfChild (Request $r) {
if (!isset($r->child_id) || !isset($r->keyword)) {
if (!isset(session()->get('children')['id']) || !isset($r->keyword)) {
return ['status_code' => 400];
}
@ -486,19 +486,19 @@ class MeetingsController extends Controller {
}
foreach ($list as $i => $l) {
if (null === ($rel = FatherRelation::select('id')->where('father_id', (int)$l->father_id)->where('child_id', (int)$r->child_id)->first())) {
if (null === ($rel = FatherRelation::select('id')->where('father_id', (int)$l->father_id)->where('child_id', (int)session()->get('children')['id'])->first())) {
continue;
}
if ($rel->child_id != (int)$rel->child_id) {
continue;
}
if (null === ($ma = MeetingApprovals::select('id')->where('child_id', (int)$r->child_id)->where('meeting_id', (int)$l->id)->whereNotNull('approval_at')->first())) {
if (null === ($ma = MeetingApprovals::select('id')->where('child_id', (int)session()->get('children')['id'])->where('meeting_id', (int)$l->id)->whereNotNull('approval_at')->first())) {
continue;
}
if (null === ($l->father = Father::select($father_select)->where('id', (int)$l->father_id)->first())) {
$l->father = new \stdClass();
}
if (null === ($l->approval = MeetingApprovals::select($meeting_approvals_select)->where('child_id', (int)$r->child_id)->whereNotNull('approval_at')->first())) {
if (null === ($l->approval = MeetingApprovals::select($meeting_approvals_select)->where('child_id', (int)session()->get('children')['id'])->whereNotNull('approval_at')->first())) {
$l->approval = new \stdClass();
}
$result[] = $l;
@ -508,7 +508,7 @@ class MeetingsController extends Controller {
}
public function searchOfNonApprovalOfChild (Request $r) {
if (!isset($r->child_id) || !isset($r->keyword)) {
if (!isset(session()->get('children')['id']) || !isset($r->keyword)) {
return ['status_code' => 400];
}
@ -523,19 +523,19 @@ class MeetingsController extends Controller {
}
foreach ($list as $i => $l) {
if (null === ($rel = FatherRelation::select('id')->where('father_id', (int)$l->father_id)->where('child_id', (int)$r->child_id)->first())) {
if (null === ($rel = FatherRelation::select('id')->where('father_id', (int)$l->father_id)->where('child_id', (int)session()->get('children')['id'])->first())) {
continue;
}
if ($rel->child_id != (int)$rel->child_id) {
continue;
}
if (null === ($ma = MeetingApprovals::select('id')->where('child_id', (int)$r->child_id)->where('meeting_id', (int)$l->id)->whereNull('approval_at')->first())) {
if (null === ($ma = MeetingApprovals::select('id')->where('child_id', (int)session()->get('children')['id'])->where('meeting_id', (int)$l->id)->whereNull('approval_at')->first())) {
continue;
}
if (null === ($l->father = Father::select($father_select)->where('id', (int)$l->father_id)->first())) {
$l->father = new \stdClass();
}
if (null === ($l->approval = MeetingApprovals::select($meeting_approvals_select)->where('child_id', (int)$r->child_id)->whereNull('approval_at')->first())) {
if (null === ($l->approval = MeetingApprovals::select($meeting_approvals_select)->where('child_id', (int)session()->get('children')['id'])->whereNull('approval_at')->first())) {
$l->approval = new \stdClass();
}
$result[] = $l;
@ -545,7 +545,7 @@ class MeetingsController extends Controller {
}
public function searchOfCompleteofFather (Request $r) {
if (!isset($r->father_id) || !isset($r->keyword)) {
if (!isset(session()->get('fathers')['id']) || !isset($r->keyword)) {
return ['status_code' => 400];
}
@ -560,7 +560,7 @@ class MeetingsController extends Controller {
}
foreach ($list as $i => $l) {
if ($l->father_id != (int)$r->father_id) {
if ($l->father_id != (int)session()->get('fathers')['id']) {
continue;
}
@ -596,7 +596,7 @@ class MeetingsController extends Controller {
}
public function searchOfIncompleteofFather (Request $r) {
if (!isset($r->father_id) || !isset($r->keyword)) {
if (!isset(session()->get('fathers')['id']) || !isset($r->keyword)) {
return ['status_code' => 400];
}
@ -611,7 +611,7 @@ class MeetingsController extends Controller {
}
foreach ($list as $i => $l) {
if ($l->father_id != (int)$r->father_id) {
if ($l->father_id != (int)session()->get('fathers')['id']) {
continue;
}

ファイルの表示

@ -39,7 +39,7 @@ Route::group(['prefix' => 'admin'], function () {
Route::put('/updateProfile/{father_id}', '\App\Http\Controllers\Api\FathersController@updateProfile')->name('pua');
Route::put('/updatePassword/{father_id}', '\App\Http\Controllers\Api\FathersController@updatePassword')->name('ppa');
Route::get('/detail/{father_id}', '\App\Http\Controllers\Api\FathersController@detail')->name('pda');
Route::delete('/delete/{father_id}', '\App\Http\Controllers\Api\FathersController@withdrawal');
Route::delete('/delete/{father_id}', '\App\Http\Controllers\Api\FathersController@withdrawal')->name('pwa');
Route::post('/registerTemporary', '\App\Http\Controllers\Api\FathersController@registerTemporary');
});
@ -51,7 +51,7 @@ Route::group(['prefix' => 'admin'], function () {
Route::put('/updateImage/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updateImage')->name('cia');
Route::put('/updatePassword/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updatePassword')->name('cpa');
Route::get('/detail/{child_id}', '\App\Http\Controllers\Api\ChildrenController@detail')->name('cda');
Route::delete('/delete/{child_id}', '\App\Http\Controllers\Api\ChildrenController@withdrawal');
Route::delete('/delete/{child_id}', '\App\Http\Controllers\Api\ChildrenController@withdrawal')->name('cwa');
});
// MeetingsController
@ -59,21 +59,21 @@ Route::group(['prefix' => 'admin'], function () {
Route::get('/list', '\App\Http\Controllers\Api\MeetingsController@list');
Route::get('/search', '\App\Http\Controllers\Api\MeetingsController@search');
Route::get('/detail/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@detail')->name('mda');
Route::put('/update/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@update');
Route::delete('/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@delete');
Route::put('/update/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@update')->name('mua');
Route::delete('/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@delete')->name('mra');
});
Route::group(['prefix' => 'meeting'], function () {
// MeetingImagesController
Route::group(['prefix' => 'images'], function () {
Route::post('/register', '\App\Http\Controllers\Api\MeetingImagesController@register');
Route::delete('/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingImagesController@delete');
Route::post('/register', '\App\Http\Controllers\Api\MeetingImagesController@register')->name('mira');
Route::delete('/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingImagesController@delete')->name('mida');
});
// MeetingApprovalsController
Route::group(['prefix' => 'approvals'], function () {
Route::post('/register', '\App\Http\Controllers\Api\MeetingApprovalsController@register');
Route::delete('/delete', '\App\Http\Controllers\Api\MeetingApprovalsController@delete');
Route::post('/register', '\App\Http\Controllers\Api\MeetingApprovalsController@register')->name('mara');
Route::delete('/delete', '\App\Http\Controllers\Api\MeetingApprovalsController@delete')->name('mada');
});
});
});
@ -93,7 +93,7 @@ Route::group(['prefix' => 'fathers'], function () {
Route::group(['middleware' => ['auth:fathers', 'notice.incomplete']], function () {
Route::put('/updateImage/{father_id}', '\App\Http\Controllers\Api\FathersController@updateImage')->name('pip');
Route::put('/updateProfile/{father_id}', '\App\Http\Controllers\Api\FathersController@updateProfile')->name('pup');
Route::delete('/withdrawal', '\App\Http\Controllers\Api\FathersController@withdrawal');
Route::delete('/withdrawal', '\App\Http\Controllers\Api\FathersController@withdrawal')->name('pwp');
Route::get('/detail/{father_id}', '\App\Http\Controllers\Api\FathersController@detail')->name('pdp');
Route::post('/meetingNotification', '\App\Http\Controllers\Api\FathersController@approvalNotification')->name('cmnotifynew');
Route::post('/meetingEditNotification', '\App\Http\Controllers\Api\FathersController@approvalNotification')->name('cmnotifyedit');
@ -118,22 +118,22 @@ Route::group(['prefix' => 'fathers'], function () {
Route::get('/searchOfCompleteOfFather', '\App\Http\Controllers\Api\MeetingsController@searchOfCompleteOfFather');
Route::get('/searchOfIncompleteOfFather', '\App\Http\Controllers\Api\MeetingsController@searchOfIncompleteOfFather');
Route::get('/detail/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@detail')->name('mdp');
Route::put('/update/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@update');
Route::delete('/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@delete');
Route::put('/update/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@update')->name('mup');
Route::delete('/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingsController@delete')->name('mrp');
Route::put('/updateMemo', '\App\Http\Controllers\Api\MeetingsController@updateMemo');
});
Route::group(['prefix' => 'meeting'], function () {
// MeetingImagesController
//rMeetingImagesController
Route::group(['prefix' => 'images'], function () {
Route::post('/register', '\App\Http\Controllers\Api\MeetingImagesController@register');
Route::delete('/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingImagesController@delete');
Route::post('/register', '\App\Http\Controllers\Api\MeetingImagesController@register')->name('mirp');
Route::delete('/delete/{meeting_id}', '\App\Http\Controllers\Api\MeetingImagesController@delete')->name('midp');
});
// MeetingApprovalsController
Route::group(['prefix' => 'approvals'], function () {
Route::post('/register', '\App\Http\Controllers\Api\MeetingApprovalsController@register');
Route::delete('/delete', '\App\Http\Controllers\Api\MeetingApprovalsController@delete');
Route::post('/register', '\App\Http\Controllers\Api\MeetingApprovalsController@register')->name('marp');
Route::delete('/delete', '\App\Http\Controllers\Api\MeetingApprovalsController@delete')->name('madp');
Route::post('/listChildrenOfMeeting', '\App\Http\Controllers\Api\MeetingApprovalsController@listChildrenOfMeeting');
Route::get('/listChildrenOfApprovel', '\App\Http\Controllers\Api\MeetingApprovalsController@listChildrenOfApprovel');
Route::get('/listChildrenOfUnapprovel', '\App\Http\Controllers\Api\MeetingApprovalsController@listChildrenOfUnapprovel');
@ -164,7 +164,7 @@ Route::group(['prefix' => 'children'], function () {
Route::get('/detail/{child_id}', '\App\Http\Controllers\Api\ChildrenController@detail')->name('cdc');
Route::put('/updateImage/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updateImage')->name('cic');
Route::put('/updateProfile/{child_id}', '\App\Http\Controllers\Api\ChildrenController@updateProfile')->name('cuc');
Route::delete('/withdrawal', '\App\Http\Controllers\Api\ChildrenController@withdrawal');
Route::delete('/withdrawal', '\App\Http\Controllers\Api\ChildrenController@withdrawal')->name('cwc');
// FathersController
Route::group(['prefix' => 'fathers'], function () {