MeetingsのPOSTの全部
このコミットが含まれているのは:
コミット
36cd7617e0
|
@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
|
|||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
use App\Models\Meeting;
|
||||
use App\Models\MeetingImage;
|
||||
|
@ -12,9 +13,49 @@ use App\Models\Child;
|
|||
use App\Models\Father;
|
||||
|
||||
class MeetingsController extends Controller {
|
||||
public function register () {}
|
||||
public function register (Request $r) {
|
||||
if (!isset($r->father_id)) {
|
||||
return ['status_code' => 400, 'error_messages' => 'ミーティングの登録に失敗しました。'];
|
||||
}
|
||||
|
||||
public function registerFavorite () {}
|
||||
$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()];
|
||||
}
|
||||
|
||||
$create = [
|
||||
'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' => 'ミーティングの登録に成功しました。'];
|
||||
}
|
||||
|
||||
return ['status_code' => 400, 'error_messages' => 'ミーティングの登録に失敗しました。'];
|
||||
}
|
||||
|
||||
public function registerFavorite (Request $r) {
|
||||
if (!isset($r->meeting_id) || !isset($r->is_favorite) || $r->is_favorite > 1) {
|
||||
return ['status_code' => 400];
|
||||
}
|
||||
|
||||
$update = ['is_favorite' => $r->is_favorite];
|
||||
|
||||
if (Meeting::where('id', $r->meeting_id)->update($update)) {
|
||||
return ['status_code' => 200];
|
||||
}
|
||||
|
||||
return ['status_code' => 400];
|
||||
}
|
||||
|
||||
public function list () {
|
||||
// adminsのみ
|
||||
|
|
|
@ -79,7 +79,7 @@ return [
|
|||
'max' => [
|
||||
'numeric' => 'The :attribute must not be greater than :max.',
|
||||
'file' => 'プロフィール画像は最大1M以内です。',
|
||||
'string' => 'The :attribute must not be greater than :max characters.',
|
||||
'string' => '本文は最大 :attribute 文字以内です。',
|
||||
'array' => 'The :attribute must not have more than :max items.',
|
||||
],
|
||||
'mimes' => 'ファイル形式は :values のみです。',
|
||||
|
@ -97,7 +97,7 @@ return [
|
|||
'password' => 'The password is incorrect.',
|
||||
'present' => 'The :attribute field must be present.',
|
||||
'regex' => 'The :attribute format is invalid.',
|
||||
'required' => 'The :attribute field is required.',
|
||||
'required' => ' :attribute は必須です。',
|
||||
'required_if' => 'The :attribute field is required when :other is :value.',
|
||||
'required_unless' => 'The :attribute field is required unless :other is in :values.',
|
||||
'required_with' => 'The :attribute field is required when :values is present.',
|
||||
|
@ -112,7 +112,7 @@ return [
|
|||
'numeric' => 'The :attribute must be :size.',
|
||||
'file' => 'The :attribute must be :size kilobytes.',
|
||||
'string' => 'The :attribute must be :size characters.',
|
||||
'array' => 'The :attribute must contain :size items.',
|
||||
'array' => ' :size 枚以上登録できません。',
|
||||
],
|
||||
'starts_with' => 'The :attribute must start with one of the following: :values.',
|
||||
'string' => 'The :attribute must be a string.',
|
||||
|
|
|
@ -34,8 +34,8 @@ Route::delete('/email-activations/deleteRelationOfFather/', '\App\Http\Controlle
|
|||
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::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');
|
||||
|
|
新しいイシューから参照