Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Mar 23, 2021
1 parent 58c82c8 commit 09db7bd
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions eloquent.md
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ To delete a model, you may call the `delete` method on the model instance:
$flight->delete();

You may call the `truncate` method to delete all of the model's associated database records. The `truncate` operation will also reset any auto-incrementing IDs on the model's associated table:

Flight::truncate();

<a name="deleting-an-existing-model-by-its-primary-key"></a>
Expand Down Expand Up @@ -1232,7 +1232,10 @@ To register an observer, you need to call the `observe` method on the model you
User::observe(UserObserver::class);
}

When models are being created inside a database transaction, you may want to instruct an observer to only run these event handlers after the database transaction (if any) is committed:
<a name="observers-and-database-transactions"></a>
#### Observers & Database Transactions

When models are being created within a database transaction, you may want to instruct an observer to only execute its event handlers after the database transaction is committed. You may accomplish this by defining an `$afterCommit` property on the observer. If a database transaction is not in progress, the event handlers will execute immediately:

<?php

Expand All @@ -1243,8 +1246,7 @@ When models are being created inside a database transaction, you may want to ins
class UserObserver
{
/**
* Indicates if the model events should be fired
* after database transactions are committed.
* Handle events after all transactions are committed.
*
* @var bool
*/
Expand All @@ -1262,7 +1264,6 @@ When models are being created inside a database transaction, you may want to ins
}
}


<a name="muting-events"></a>
### Muting Events

Expand Down

0 comments on commit 09db7bd

Please sign in to comment.