DB::beginTransaction();
try {
$project = Project::find($id);
$project->users()->detach();
$project->delete();
DB::commit();
} catch (Exception $ex) {
DB::rollback();
return response()->json(['error' => $ex->getMessage()], 500);
}
DB::beginTransaction();
try {
DB::insert(...);
DB::insert(...);
DB::insert(...);
DB::commit();
// all good
} catch (Exception $e) {
DB::rollback();
// something went wrong
}
DB::beginTransaction();
try {
DB::insert(...);
DB::commit();
} catch (Exception $e) {
DB::rollback();
throw $e;
} catch (Throwable $e) {
DB::rollback();
throw $e;
}
DB::beginTransaction();
try{
DB::Commit();
} catch (Exception $e) {
DB::rollback();
}
DB::beginTransaction();
try { /** Statement */ DB::commit(); }
catch (Exception $e) { /** Statement if failed */ DB::rollback(); }
Code Example |
---|
Php :: |
Php :: return error when duplicated laravel |
:: |
:: |
:: magento 2 status mode |
:: |
Php :: |
:: |
:: |
:: |
Php :: |
:: |
:: laravel jetstream livewire |
:: |
:: |
:: |
:: php escape special characters |
:: |
:: |
:: Internal error: xmlSchemaValidateChildElem, calling xmlRegExecPushString2(). |
:: |
:: |
Php :: laravel word count utf8 |
:: unique laravel migration |
Php :: |
:: |
:: incorrect format parameter phpmyadmin xampp |
:: |
Php :: |
:: |