このコミットが含まれているのは:
守矢諏訪子 2021-11-01 01:08:02 +09:00
コミット b14d1fa77a
2個のファイルの変更18行の追加0行の削除

ファイルの表示

@ -501,6 +501,16 @@ class MeetingsController extends Controller {
'memo' => 'nullable|max:2000',
]);
// ミームタイプ
Validator::extend('pdf_meme', function ($attribute, $value, $params, $validator) {
try {
return mime_content_type($value) == 'application/pdf';
} catch (\Throwable $e) {
Log::critical($e->getMessage());
return false;
}
});
if ($validate->fails()) {
return ['status_code' => 422, 'error_messages' => $validate->errors()];
}
@ -517,6 +527,13 @@ class MeetingsController extends Controller {
$filename = uniqid() . '.pdf';
$pdf = base64_decode(substr($r->pdf, strpos($r->pdf, ',') + 1));
$update['pdf'] = '/storage/'.$filename;
if ($chk = Meeting::select('pdf')->where('id', (int)$meeting_id)->first()) {
if (Storage::disk('public')->has($chk->pdf)) {
Storage::disk('public')->delete($chk->pdf);
}
}
Storage::disk('public')->put($filename, $pdf);
}

ファイルの表示

@ -106,6 +106,7 @@ return [
'required_with_all' => 'The :attribute field is required when :values are present.',
'required_without' => 'The :attribute field is required when :values is not present.',
'required_without_all' => 'The :attribute field is required when none of :values are present.',
'pdf_meme' => 'ファイル形式はpdfのみです。',
'prohibited' => 'The :attribute field is prohibited.',
'prohibited_if' => 'The :attribute field is prohibited when :other is :value.',
'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.',