3
In the Laravel
, i know that attributes can return an object of type Carbon\Carbon
(an extension of DateTime
php), if the field is created_at or updated_at.
Example:
$usuario = Usuario::find(1);
// Não é uma string, é um Carbon\Carbon(object)
$usuario->created_at->format('d/m/Y');
But I would like to do this with an attribute like tinyint
.
For example, in the model Usuario
i have returned attribute from table called ativo
.
Instead of returning 1
or 0
model, I wish she’d already return to me "sim"
or "não"
.
It is possible to do this in the Laravel
?
A link to documentation and use the name of this resource would be more interesting.
atributo método mágico
can generate confusion with the__get
of PHP.– gmsantos