mercredi 26 octobre 2016

Laravel Models - Casting dates to Carbon instances

In a Laravel model it is possible to casts fields as Carbon dates like so:

class Example extends Model
{
    protected $casts = [
        'date_of_birth' => 'date'
    ]
}

However this can also be done like so:

class Example extends Model
{
    protected $dates= [
        'date_of_birth'
    ]
}

What is the difference and what is the recommended way of doing this?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2eH5VJT
via IFTTT

Aucun commentaire:

Enregistrer un commentaire