In Laravel
, I know that attributes can return an object of type Carbon\Carbon
(an extension of DateTime
of 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'd like to do this with an attribute of type tinyint
.
For example, in the Usuario
model I have the attribute returned from the table named ativo
.
Instead of returning 1
or 0
of the model, I'd like it to return "sim"
or "não"
.
Is it possible to do this in Laravel
?