Merge branch 'backend' of https://github.com/nakazawakan/kikikanri into p_account
このコミットが含まれているのは:
コミット
8218e4f43b
|
@ -21,6 +21,45 @@ class MeetingsController extends Controller {
|
||||||
return ['status_code' => 400, 'error_messages' => ['ミーティングの登録に失敗しました。']];
|
return ['status_code' => 400, 'error_messages' => ['ミーティングの登録に失敗しました。']];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tmp
|
||||||
|
/////////////////////////
|
||||||
|
// ファイルサイズは10MiB以内
|
||||||
|
Validator::extend('image_size', function ($attribute, $value, $params, $validator) {
|
||||||
|
try {
|
||||||
|
$ok = true;
|
||||||
|
foreach ($value as $v) {
|
||||||
|
if (strlen(base64_decode($v)) > 1048576) {
|
||||||
|
$ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ok;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::critical($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// ミームタイプ
|
||||||
|
Validator::extend('image_meme', function ($attribute, $value, $params, $validator) {
|
||||||
|
try {
|
||||||
|
$ok = true;
|
||||||
|
foreach ($value as $v) {
|
||||||
|
if (
|
||||||
|
mime_content_type($v) == 'image/jpeg' || // jpg
|
||||||
|
mime_content_type($v) == 'image/png' || // png
|
||||||
|
mime_content_type($v) == 'image/gif' // gif
|
||||||
|
) {
|
||||||
|
$ok = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $ok;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::critical($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
/////////////////////////
|
||||||
|
|
||||||
// ミームタイプ
|
// ミームタイプ
|
||||||
Validator::extend('pdf_meme', function ($attribute, $value, $params, $validator) {
|
Validator::extend('pdf_meme', function ($attribute, $value, $params, $validator) {
|
||||||
try {
|
try {
|
||||||
|
@ -35,7 +74,8 @@ class MeetingsController extends Controller {
|
||||||
'title' => 'required|max:100',
|
'title' => 'required|max:100',
|
||||||
'text' => 'required|max:2000',
|
'text' => 'required|max:2000',
|
||||||
'memo' => 'max:2000',
|
'memo' => 'max:2000',
|
||||||
'pdf' => 'pdf_meme'
|
'pdf' => 'pdf_meme',
|
||||||
|
'image' => 'image_size|image_meme', // tmp
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($validate->fails()) {
|
if ($validate->fails()) {
|
||||||
|
@ -58,14 +98,33 @@ class MeetingsController extends Controller {
|
||||||
Storage::disk('public')->put($filename, $pdf);
|
Storage::disk('public')->put($filename, $pdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
Meeting::create($insert);
|
$id = Meeting::create($insert);
|
||||||
|
|
||||||
|
// tmp
|
||||||
|
/////////////////////////
|
||||||
|
foreach ($r->image as $img) {
|
||||||
|
$ext = explode('/', mime_content_type($img))[1];
|
||||||
|
$filename = uniqid() . '.'.$ext;
|
||||||
|
$image = base64_decode(substr($img, strpos($img, ',') + 1));
|
||||||
|
Storage::disk('public')->put($filename, $image);
|
||||||
|
|
||||||
|
$insert_image = [
|
||||||
|
'meeting_id' => (int)$id,
|
||||||
|
'image' => '/storage/'.$filename,
|
||||||
|
];
|
||||||
|
|
||||||
|
MeetingImage::create($insert_image);
|
||||||
|
}
|
||||||
|
/////////////////////////
|
||||||
|
|
||||||
|
$params = ['meeting_id' => $id];
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
// 失敗
|
// 失敗
|
||||||
Log::critical($e->getMessage());
|
Log::critical($e->getMessage());
|
||||||
return ['status_code' => 400, 'error_messages' => ['ミーティングの登録に失敗しました。']];
|
return ['status_code' => 400, 'error_messages' => ['ミーティングの登録に失敗しました。']];
|
||||||
}
|
}
|
||||||
|
|
||||||
return ['status_code' => 200, 'success_messages' => ['ミーティングの登録に成功しました。']];
|
return ['status_code' => 200, 'success_messages' => ['ミーティングの登録に成功しました。'], 'params' => $params];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerFavorite (Request $r) {
|
public function registerFavorite (Request $r) {
|
||||||
|
@ -579,12 +638,6 @@ class MeetingsController extends Controller {
|
||||||
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' => 'nullable|max:2000',
|
|
||||||
]);
|
|
||||||
|
|
||||||
// ミームタイプ
|
// ミームタイプ
|
||||||
Validator::extend('pdf_meme', function ($attribute, $value, $params, $validator) {
|
Validator::extend('pdf_meme', function ($attribute, $value, $params, $validator) {
|
||||||
try {
|
try {
|
||||||
|
@ -595,6 +648,13 @@ class MeetingsController extends Controller {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$validate = Validator::make($r->all(), [
|
||||||
|
'title' => 'required|max:100',
|
||||||
|
'text' => 'required|max:2000',
|
||||||
|
'memo' => 'nullable|max:2000',
|
||||||
|
'pdf' => 'pdf_meme',
|
||||||
|
]);
|
||||||
|
|
||||||
if ($validate->fails()) {
|
if ($validate->fails()) {
|
||||||
return ['status_code' => 422, 'error_messages' => $validate->errors()];
|
return ['status_code' => 422, 'error_messages' => $validate->errors()];
|
||||||
}
|
}
|
||||||
|
|
新しいイシューから参照