trait ManagesTransactions (View source)

Methods

mixed
transaction(Closure $callback, int $attempts = 1)

Execute a Closure within a transaction.

void
handleTransactionException(Exception $e, int $currentAttempt, int $maxAttempts)

Handle an exception encountered when running a transacted statement.

void
beginTransaction()

Start a new database transaction.

void
createTransaction()

Create a transaction within the database.

void
createSavepoint()

Create a save point within the database.

void
handleBeginTransactionException(Throwable $e)

Handle an exception from a transaction beginning.

void
commit()

Commit the active database transaction.

void
handleCommitTransactionException(Exception $e, int $currentAttempt, int $maxAttempts)

Handle an exception encountered when committing a transaction.

void
rollBack(int|null $toLevel = null)

Rollback the active database transaction.

void
performRollBack(int $toLevel)

Perform a rollback within the database.

void
handleRollBackException(Exception $e)

Handle an exception from a rollback.

int
transactionLevel()

Get the number of active transactions.

Details

mixed transaction(Closure $callback, int $attempts = 1)

Execute a Closure within a transaction.

Parameters

Closure $callback
int $attempts

Return Value

mixed

Exceptions

Throwable

protected void handleTransactionException(Exception $e, int $currentAttempt, int $maxAttempts)

Handle an exception encountered when running a transacted statement.

Parameters

Exception $e
int $currentAttempt
int $maxAttempts

Return Value

void

Exceptions

Exception

void beginTransaction()

Start a new database transaction.

Return Value

void

Exceptions

Exception

protected void createTransaction()

Create a transaction within the database.

Return Value

void

protected void createSavepoint()

Create a save point within the database.

Return Value

void

protected void handleBeginTransactionException(Throwable $e)

Handle an exception from a transaction beginning.

Parameters

Throwable $e

Return Value

void

Exceptions

Exception

void commit()

Commit the active database transaction.

Return Value

void

protected void handleCommitTransactionException(Exception $e, int $currentAttempt, int $maxAttempts)

Handle an exception encountered when committing a transaction.

Parameters

Exception $e
int $currentAttempt
int $maxAttempts

Return Value

void

void rollBack(int|null $toLevel = null)

Rollback the active database transaction.

Parameters

int|null $toLevel

Return Value

void

Exceptions

Exception

protected void performRollBack(int $toLevel)

Perform a rollback within the database.

Parameters

int $toLevel

Return Value

void

protected void handleRollBackException(Exception $e)

Handle an exception from a rollback.

Parameters

Exception $e

Return Value

void

Exceptions

Exception

int transactionLevel()

Get the number of active transactions.

Return Value

int

Laravel Cloud is the best place to deploy Laravel, Nuxt, Express, Hono, Node.js, Bun, Go, Flask, Python, and more, with dedicated infrastructure available on AWS through Laravel Private Cloud.