Skip to content

Commit 09db7bd

Browse files
committed
formatting
1 parent 58c82c8 commit 09db7bd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

eloquent.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ To delete a model, you may call the `delete` method on the model instance:
714714
$flight->delete();
715715

716716
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:
717-
717+
718718
Flight::truncate();
719719

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

1235-
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:
1235+
<a name="observers-and-database-transactions"></a>
1236+
#### Observers & Database Transactions
1237+
1238+
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:
12361239

12371240
<?php
12381241

@@ -1243,8 +1246,7 @@ When models are being created inside a database transaction, you may want to ins
12431246
class UserObserver
12441247
{
12451248
/**
1246-
* Indicates if the model events should be fired
1247-
* after database transactions are committed.
1249+
* Handle events after all transactions are committed.
12481250
*
12491251
* @var bool
12501252
*/
@@ -1262,7 +1264,6 @@ When models are being created inside a database transaction, you may want to ins
12621264
}
12631265
}
12641266

1265-
12661267
<a name="muting-events"></a>
12671268
### Muting Events
12681269

0 commit comments

Comments
 (0)