Skip to content

Commit d17c030

Browse files
committed
Merge branch 'auto_deleted_at_cast' of https://github.com/timacdonald/docs into timacdonald-auto_deleted_at_cast
2 parents e71291c + 8f5711f commit d17c030

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

eloquent.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ Of course, you may also run a delete statement on a set of models. In this examp
486486
<a name="soft-deleting"></a>
487487
### Soft Deleting
488488

489-
In addition to actually removing records from your database, Eloquent can also "soft delete" models. When models are soft deleted, they are not actually removed from your database. Instead, a `deleted_at` attribute is set on the model and inserted into the database. If a model has a non-null `deleted_at` value, the model has been soft deleted. To enable soft deletes for a model, use the `Illuminate\Database\Eloquent\SoftDeletes` trait on the model and add the `deleted_at` column to your `$dates` property:
489+
In addition to actually removing records from your database, Eloquent can also "soft delete" models. When models are soft deleted, they are not actually removed from your database. Instead, a `deleted_at` attribute is set on the model and inserted into the database. If a model has a non-null `deleted_at` value, the model has been soft deleted. To enable soft deletes for a model, use the `Illuminate\Database\Eloquent\SoftDeletes` trait on the model:
490490

491491
<?php
492492

@@ -498,15 +498,10 @@ In addition to actually removing records from your database, Eloquent can also "
498498
class Flight extends Model
499499
{
500500
use SoftDeletes;
501-
502-
/**
503-
* The attributes that should be mutated to dates.
504-
*
505-
* @var array
506-
*/
507-
protected $dates = ['deleted_at'];
508501
}
509502

503+
In addition, the `SoftDeletes` trait will cast the `deleted_at` attribute to a `DateTime` / `Carbon` instance for you.
504+
510505
Of course, you should add the `deleted_at` column to your database table. The Laravel [schema builder](/docs/{{version}}/migrations) contains a helper method to create this column:
511506

512507
Schema::table('flights', function (Blueprint $table) {

0 commit comments

Comments
 (0)