MeetingsControllerとMeetingImagesControllerの今まで作ったもの

このコミットが含まれているのは:
守矢諏訪子 2021-09-30 13:33:23 +09:00
コミット 429bf44e0e
5個のファイルの変更337行の追加2行の削除

ファイルの表示

@ -9,6 +9,12 @@ use App\Models\Father;
use App\Models\FatherRelation;
class FathersController extends Controller {
public function login () {}
public function registerTemporary () {}
public function registerMain () {}
public function list () {
$result = [];
$father_select = ['id', 'company', 'image'];
@ -59,6 +65,12 @@ class FathersController extends Controller {
return ['status_code' => 400];
}
public function updateImage ($father_id) {}
public function updateProfile ($father_id) {}
public function updatePassword ($father_id) {}
public function delete ($father_id) {
// 削除成功
if (Father::where('id', $father_id)->delete()) {
@ -68,4 +80,6 @@ class FathersController extends Controller {
// 削除失敗
return ['status_code' => 400];
}
public function checkEmail () {}
}

ファイルの表示

@ -0,0 +1,28 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use App\Models\MeetingImage;
class MeetingImagesController extends Controller {
public function register (Request $r) {
$validate = Validator::make($r->all(), ['image' => 'max:1024|mimes:jpg,png,gif']);
$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()];
foreach ($r->images as $image) { if (!MeetingImage::insert(['meeting_id' => $meeting_id, 'image' => $image])) return ['status_code' => 400]; }
return ['status_code' => 200];
}
public function deleteRelationMeeting ($meeting_id) {
// 削除成功
if (MeetingImage::where('meeting_id', $meeting_id)->delete()) return ['status_code' => 200];
// 削除失敗
return ['status_code' => 400];
}
}

ファイルの表示

@ -0,0 +1,250 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\Meeting;
use App\Models\MeetingImage;
use App\Models\MeetingApprovals;
use App\Models\Child;
use App\Models\Father;
class MeetingsController extends Controller {
public function register () {}
public function registerFavorite () {}
public function list () {
// 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'];
// 取得に成功
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];
}
// 取得に失敗
return ['status_code' => 400];
}
public function listOfApprovalOfChild (Request $r) {
if (!isset($r->child_id)) {
return ['status_code' => 400];
}
$result = [];
$meeting_select = ['id', 'father_id', 'title', 'text', 'memo', 'updated_at'];
$meeting_images_select = ['image'];
$father_select = ['image', 'company'];
$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();
}
return ['status_code' => 200, 'params' => $result];
}
}
}
// 取得に失敗
return ['status_code' => 400];
}
public function listOfNonApprovalOfChild (Request $r) {
if (!isset($r->child_id)) {
return ['status_code' => 400];
}
$result = [];
$meeting_select = ['id', 'father_id', 'title', 'text', 'memo', 'updated_at'];
$meeting_images_select = ['image'];
$father_select = ['image', 'company'];
$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();
}
return ['status_code' => 200, 'params' => $result];
}
}
}
// 取得に失敗
return ['status_code' => 400];
}
public function listOfCompleteOfFather (Request $r) {
if (!isset($r->father_id)) {
return ['status_code' => 400];
}
$result = [];
$meeting_select = ['id', 'father_id', 'title', 'text', 'memo', 'updated_at'];
$meeting_approvals_select = ['child_id', 'approval_at'];
$child_select = ['image'];
// 取得に成功
if ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['approvals'] = MeetingApprovals::select($meeting_approvals_select)->whereNotNull('approval_at')->where('meeting_id', $l['id'])->orderBy('updated_at', 'desc')->get();
if (count($result[$i]['approvals']) == 0) {
unset($result[$i]);
continue;
}
foreach ($result[$i]['approvals'] as $ii => $ra) {
$result[$i]['approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['approvals'][$ii]['child_id'])->first();
}
}
return ['status_code' => 200, 'params' => $result];
}
// 取得に失敗
return ['status_code' => 400];
}
public function listOfIncompleteOfFather (Request $r) {
if (!isset($r->father_id)) {
return ['status_code' => 400];
}
$result = [];
$meeting_select = ['id', 'father_id', 'title', 'text', 'memo', 'updated_at'];
$meeting_approvals_select = ['child_id', 'approval_at'];
$child_select = ['image'];
// 取得に成功
if ($list = Meeting::select($meeting_select)->where('father_id', $r->father_id)->get()->toArray()) {
foreach ($list as $i => $l) {
$result[] = $l;
$result[$i]['approvals'] = MeetingApprovals::select($meeting_approvals_select)->whereNull('approval_at')->where('meeting_id', $l['id'])->orderBy('updated_at', 'desc')->get();
if (count($result[$i]['approvals']) > 1) {
unset($result[$i]);
continue;
}
foreach ($result[$i]['approvals'] as $ii => $ra) {
$result[$i]['approvals'][$ii]['child'] = Child::select($child_select)->where('id', $result[$i]['approvals'][$ii]['child_id'])->first();
}
}
return ['status_code' => 200, 'params' => $result];
}
// 取得に失敗
return ['status_code' => 400];
}
public function listOfFavoriteofFather (Request $r) {
if (!isset($r->father_id)) {
return ['status_code' => 400];
}
$result = [];
$meeting_select = ['id', 'father_id', 'title', 'text', 'memo', 'updated_at', 'is_favorite'];
$meeting_approvals_select = ['child_id', 'approval_at'];
$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];
}
// 取得に失敗
return ['status_code' => 400];
}
public function listOfNonFavoriteofFather (Request $r) {
if (!isset($r->father_id)) {
return ['status_code' => 400];
}
$result = [];
$meeting_select = ['id', 'father_id', 'title', 'text', 'memo', 'updated_at', 'is_favorite'];
$meeting_approvals_select = ['child_id', 'approval_at'];
$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];
}
// 取得に失敗
return ['status_code' => 400];
}
public function searchOfApprovalOfChild (Request $r) {}
public function searchOfNonApprovalOfChild (Request $r) {}
public function searchOfCompleteofFather (Request $r) {}
public function searchOfIncompleteofFather (Request $r) {}
public function detail ($meeting_id) {}
public function delete ($meeting_id) {
// 削除成功
if (Meetings::where('meeting_id', $meeting_id)->delete()) return ['status_code' => 200];
// 削除失敗
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];
}
}

ファイルの表示

@ -78,11 +78,11 @@ return [
],
'max' => [
'numeric' => 'The :attribute must not be greater than :max.',
'file' => 'The :attribute must not be greater than :max kilobytes.',
'file' => 'プロフィール画像は最大1M以内です。',
'string' => 'The :attribute must not be greater than :max characters.',
'array' => 'The :attribute must not have more than :max items.',
],
'mimes' => 'The :attribute must be a file of type: :values.',
'mimes' => 'ファイル形式は :values のみです。',
'mimetypes' => 'The :attribute must be a file of type: :values.',
'min' => [
'numeric' => 'The :attribute must be at least :min.',

ファイルの表示

@ -15,10 +15,17 @@ 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');
@ -26,20 +33,56 @@ Route::delete('/email-activations/deleteRelationOfFather/', '\App\Http\Controlle
// 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::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');