Skip to content

Commit c5c07fa

Browse files
Removed deprecated date casting.
1 parent 66ade93 commit c5c07fa

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

docs/model.md

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ class CreateGameLeaderboardsTable extends Migration
5959

6060
When creating a model, the following logic will be automated for you:
6161

62-
* [Attribute Casting](https://laravel.com/docs/eloquent-mutators#attribute-casting) their appropriate type (strings, integers, floats...).
63-
* [Serialization hiding](https://laravel.com/docs/eloquent-serialization#hiding-attributes-from-json) for sensible data.
64-
* [Mutating dates columns](https://laravel.com/docs/eloquent-mutators#date-mutators) as `date` and `datetime`.
62+
* [Attribute Casting](https://laravel.com/docs/eloquent-mutators#attribute-casting) their appropriate type (dates, strings, integers, floats...).
63+
* [Serialization hiding](https://laravel.com/docs/eloquent-serialization#hiding-attributes-from-json)
6564
* [Relationships](https://laravel.com/docs/eloquent-relationships) with methods and pivot tables, if necessary.
6665
* PHPDoc mixin for Eloquent Builder, `create` and `make` methods among others (`find`, `firstOrNew`, etc.)
6766
* PHPDoc blocks for model properties and relations.
@@ -289,22 +288,20 @@ class Podcast extends Model
289288
* @var bool
290289
*/
291290
public $incrementing = false;
292-
291+
293292
/**
294-
* The number of models-properties to return for pagination.
293+
* The attributes that should be cast.
295294
*
296-
* @var int
295+
* @var array
297296
*/
298-
protected $perPage = 20;
297+
protected $casts = ['published_at' => 'datetime'];
299298

300299
/**
301-
* The attributes that should be mutated to dates.
300+
* The number of models-properties to return for pagination.
302301
*
303-
* @var array
302+
* @var int
304303
*/
305-
protected $dates = [
306-
'published_at',
307-
];
304+
protected $perPage = 20;
308305

309306
/**
310307
* The attributes that are mass assignable.

docs/samples/model.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* @property string $title
3333
* @property string $body
3434
* @property array $private_notes
35-
* @property null|\Illuminate\Support\Carbon $premium_at
35+
* @property null|\Illuminate\Support\Carbon $published_at
3636
*
3737
* @property-read \Illuminate\Support\Carbon $created_at
3838
* @property-read \Illuminate\Support\Carbon $updated_at
@@ -47,7 +47,7 @@ class Post extends Model
4747
*
4848
* @var.
4949
*/
50-
protected $casts = ['private_notes' => 'array'];
50+
protected $casts = ['private_notes' => 'array', 'published_at' => 'datetime'];
5151

5252
/**
5353
* The attributes that are mass assignable.
@@ -84,13 +84,6 @@ class Post extends Model
8484
*/
8585
protected $keyType = 'string';
8686

87-
/**
88-
* The attributes that should be mutated to dates.
89-
*
90-
* @var array
91-
*/
92-
protected $dates = ['published_at'];
93-
9487
/**
9588
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo|\App\Models\User
9689
*/

0 commit comments

Comments
 (0)