TTLを超えたら、DBから削除する
このコミットが含まれているのは:
コミット
9514daf7bc
|
@ -45,8 +45,12 @@ class ChildrenController extends Controller {
|
|||
}
|
||||
|
||||
if ($get = TelActivation::where('tel', $r->tel)->first()) {
|
||||
// すでにDBに登録されている場合
|
||||
return ['status_code' => 400, 'error_messages' => ['既に使用されている電話番号です。']];
|
||||
if (time() > strtotime($get->ttl)) {
|
||||
TelActivation::where('tel', $r->tel)->delete();
|
||||
}
|
||||
else {
|
||||
return ['status_code' => 400, 'error_messages' => ['既に使用されている電話番号です。']];
|
||||
}
|
||||
}
|
||||
|
||||
$token = bin2hex(random_bytes(24));
|
||||
|
@ -120,6 +124,7 @@ class ChildrenController extends Controller {
|
|||
$password = Hash::make($r->password);
|
||||
|
||||
$ext = explode('/', mime_content_type($r->image))[1];
|
||||
$lastid = Child::select('id')->orderBy('id', 'desc')->first();
|
||||
$filename = $this->uuidv4() . '.'.$ext;
|
||||
|
||||
$insert = [
|
||||
|
|
|
@ -94,8 +94,12 @@ class FathersController extends Controller {
|
|||
return ['status_code' => 400, 'error_messages' => ['入力したメールアドレスは既に登録済みです。同じメールアドレスは使用できません。']];
|
||||
}
|
||||
else if ($get = EmailActivation::where('email', $r->email)->first()) {
|
||||
// すでにemail_activationsに登録されている場合
|
||||
return ['status_code' => 400, 'error_messages' => ['入力したメールアドレスは既に登録済みです。同じメールアドレスは使用できません。']];
|
||||
if (time() > strtotime($get->ttl)) {
|
||||
EmailActivation::where('email', $r->email)->delete();
|
||||
}
|
||||
else {
|
||||
return ['status_code' => 400, 'error_messages' => ['入力したメールアドレスは既に登録済みです。同じメールアドレスは使用できません。']];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$token = bin2hex(random_bytes(24));
|
||||
|
@ -158,6 +162,7 @@ class FathersController extends Controller {
|
|||
$password = Hash::make($r->password);
|
||||
|
||||
$ext = explode('/', mime_content_type($r->image))[1];
|
||||
$lastid = Father::select('id')->orderBy('id', 'desc')->first();
|
||||
$filename = $this->uuidv4() . '.'.$ext;
|
||||
$image = base64_decode(substr($r->image, strpos($r->image, ',') + 1));
|
||||
Storage::disk('public')->put($filename, $image);
|
||||
|
|
|
@ -62,8 +62,12 @@ class MeetingsController extends Controller {
|
|||
|
||||
$filename = '';
|
||||
$fnames = [];
|
||||
$meeting = 0;
|
||||
|
||||
try {
|
||||
$meeting = Meeting::create($insert);
|
||||
$meeting = $meeting->id;
|
||||
|
||||
if (isset($r->pdf)) {
|
||||
$filename = $this->uuidv4() . '.pdf';
|
||||
$insert['pdf'] = '/storage/'.$filename;
|
||||
|
@ -78,8 +82,6 @@ class MeetingsController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
$meeting = Meeting::create($insert);
|
||||
|
||||
if (isset($r->image)) {
|
||||
foreach ($r->image as $img) {
|
||||
if (substr($img, -5) != '.jpeg' && substr($img, -4) != '.jpg' && substr($img, -4) != '.png' && substr($img, -4) != '.gif') {
|
||||
|
@ -89,16 +91,16 @@ class MeetingsController extends Controller {
|
|||
$image = base64_decode(substr($img, strpos($img, ',') + 1));
|
||||
Storage::disk('public')->put($fname, $image);
|
||||
|
||||
$filename = '/storage/'.$fname;
|
||||
$imgname = $fname;
|
||||
|
||||
}
|
||||
else {
|
||||
$filename = $img;
|
||||
$imgname = $img;
|
||||
}
|
||||
|
||||
$insert_image = [
|
||||
'meeting_id' => (int)$meeting->id,
|
||||
'image' => $filename,
|
||||
'meeting_id' => (int)$meeting,
|
||||
'image' => $imgname,
|
||||
];
|
||||
|
||||
MeetingImage::create($insert_image);
|
||||
|
@ -108,23 +110,25 @@ class MeetingsController extends Controller {
|
|||
foreach (json_decode($r->children) as $child) {
|
||||
$insert_approval = [
|
||||
'child_id' => $child,
|
||||
'meeting_id' => (int)$meeting->id,
|
||||
'meeting_id' => (int)$meeting,
|
||||
'approval_at' => null,
|
||||
];
|
||||
|
||||
MeetingApprovals::create($insert_approval);
|
||||
}
|
||||
|
||||
$params = ['meeting_id' => $meeting->id];
|
||||
$params = ['meeting_id' => $meeting];
|
||||
} catch (\Throwable $e) {
|
||||
// 失敗
|
||||
Log::critical($e->getMessage());
|
||||
if (isset($r->pdf)) {
|
||||
Storage::disk('public')->delete($filename);
|
||||
}
|
||||
if (isset($r->image)) {
|
||||
foreach ($fnames as $f) {
|
||||
Storage::disk('public')->delete($f);
|
||||
if (!is_null($meeting) && $meeting != 0) {
|
||||
if (isset($r->pdf)) {
|
||||
Storage::disk('public')->delete($filename);
|
||||
}
|
||||
if (isset($r->image)) {
|
||||
foreach ($fnames as $f) {
|
||||
Storage::disk('public')->delete($f);
|
||||
}
|
||||
}
|
||||
}
|
||||
return ['status_code' => 400, 'error_messages' => ['ミーティングの登録に失敗しました。']];
|
||||
|
|
新しいイシューから参照