ミーティング編集からメールを送る様に

このコミットが含まれているのは:
守矢諏訪子 2022-02-07 13:55:03 +09:00
コミット 45515e3548
1個のファイルの変更26行の追加1行の削除

ファイルの表示

@ -18,6 +18,7 @@ use App\Models\Father;
use App\Models\FatherRelation;
use App\Mail\FathersApprovalMail;
use App\Mail\MeetingEditNotification;
class MeetingsController extends Controller {
public function register (Request $r) {
@ -800,12 +801,36 @@ class MeetingsController extends Controller {
}
// データベースに保存します。
Meeting::where('id', (int)$meeting_id)->update($update);
DB::beginTransaction();
$meeting = Meeting::find((int)$meeting_id);
$meeting->title = $update['title'];
$meeting->text = $update['text'];
if (isset($update['memo'])) $meeting->memo = $update['memo'];
if (isset($update['pdf'])) $meeting->pdf = $update['pdf'];
$meeting->save();
// 子供達を知らせます。
if (null !== ($fr = FatherRelation::where('father_id', (int)session()->get('fathers')['id'])->get())) {
foreach ($fr as $f) {
if (null === ($child = Child::where('id', $f->child_id)->first())) {
Log::critical('ミーティングの編集エラー子供データが存在しません。親ID'.session()->get('fathers')['id'].'、子ID'.$f->child_id);
}
else {
Mail::to($child->email)->send(new MeetingEditNotification(session()->get('fathers')['company'], (int)$meeting_id));
}
}
}
DB::commit();
} catch (\Throwable $e) {
Log::critical($e->getMessage());
if (isset($r->pdf) && !is_null($r->pdf)) {
Storage::disk('private')->delete($filename);
}
DB::rollback();
return ['status_code' => 400];
}