I'm making a Queueing system and I want the called queue number to go back to last queue in case the user doesn't show for the transaction for a given period of time. Please help me how to do this.
This is my function for calling a queue:
public function callqueue(Request $request)
{
$request->validate([
'called' => ['max:255'],
'counter' => ['max:255']
]);
$dept = Auth::user()->department;
$call = Queue::where([
['department',$dept],
['called', 'no']
])
->whereDate('created_at', Carbon::today())
->orderBy('id', 'asc')
->first();
if ( ! is_null($call)) {
$call->update([
'called' => $request->called,
'counter' => $request->counter
]);
$call->save();
event(new NewQueue($call));
return redirect('admin')->withStatus(__('Queue has been called.'));
} else {
return redirect('admin')->withStatus(__('No available queue for calling.'));
}
}