update: ticket save lock

This commit is contained in:
tokumeikoi 2022-04-11 11:30:53 +08:00
parent 27271e3ffb
commit f439040375

View File

@ -55,7 +55,7 @@ class TicketController extends Controller
public function save(TicketSave $request) public function save(TicketSave $request)
{ {
DB::beginTransaction(); DB::beginTransaction();
if ((int)Ticket::where('status', 0)->where('user_id', $request->session()->get('id'))->count()) { if ((int)Ticket::where('status', 0)->where('user_id', $request->session()->get('id'))->lockForUpdate()->count()) {
abort(500, __('There are other unresolved tickets')); abort(500, __('There are other unresolved tickets'));
} }
$ticket = Ticket::create(array_merge($request->only([ $ticket = Ticket::create(array_merge($request->only([