P
P
Pavel2017-10-02 16:41:16
Laravel
Pavel, 2017-10-02 16:41:16

How to properly use Attribute Casting?

Hello. I found in the documentation the possibility, if I understood correctly, to cast the model properties to the desired types.
https://laravel.com/docs/5.4/eloquent-mutators#att...
But it doesn't work when the column is null. I want instead of null, for example, to get an empty string.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
JhaoDa, 2017-10-02
@Palych_tw

This is not a casting task, this is an accessor / mutator task , if you want it to work out of the box.
Well, or you can refine the casting mechanism.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question