|
|
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\admin;
|
|
|
use App\Constants\HttpStatus;
|
|
|
use App\Http\Controllers\Controller;
|
|
|
use App\Services\PcIssueService;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
use Exception;
|
|
|
use App\Models\PcIssue as PcIssueModel;
|
|
|
@@ -59,6 +60,7 @@ class PcIssue extends Controller
|
|
|
*/
|
|
|
public function preDraw()
|
|
|
{
|
|
|
+ DB::beginTransaction();
|
|
|
try {
|
|
|
request()->validate([
|
|
|
'issue_no' => ['required', 'string'],
|
|
|
@@ -78,9 +80,12 @@ class PcIssue extends Controller
|
|
|
$pcIssue->advance_code = $he;
|
|
|
$pcIssue->save();
|
|
|
$winningNumbers = PcIssueService::getWinningNumbers($keno);
|
|
|
+ DB::commit();
|
|
|
} catch (ValidationException $e) {
|
|
|
+ DB::rollBack();
|
|
|
return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first());
|
|
|
} catch (Exception $e) {
|
|
|
+ DB::rollBack();
|
|
|
if ($e->getCode() == HttpStatus::CUSTOM_ERROR) {
|
|
|
return $this->error(HttpStatus::CUSTOM_ERROR, $e->getMessage());
|
|
|
}
|