use Log;
public function function_name(Request $request)
{
try
{
$id= $request->oid;
$data = Order::where('id',$id)->first();
if (!is_null($data)) {
$result = Order::where('id', $id)->update([
'status' => "Approved",
'approved_by' => auth()->user()->name,]);
return redirect()->route('order-management')->withStatus('Status updated');
}else{
return redirect()->route('order-management')->withStatus('Record is not available.');
}
}
catch (\Exception\Database\QueryException $e)
{
Log::info('Query: '.$e->getSql());
Log::info('Query: Bindings: '.$e->getBindings());
Log::info('Error: Code: '.$e->getCode());
Log::info('Error: Message: '.$e->getMessage());
return redirect()->route('user-management')->withStatus('Internal Server Error. Please try again later.');
}
}
}
}
catch (\Exception\Database\QueryException $e)
{
Log::info('Query: '.$e->getSql());
Log::info('Query: Bindings: '.$e->getBindings());
Log::info('Error: Code: '.$e->getCode());
Log::info('Error: Message: '.$e->getMessage());
return redirect()->route('user-management')->withStatus('Internal Server Error. Please try again later.');
}
}