In Laravel 5, I have a binary field called 'microchip,' which is a binary field. I would like to build an accessor function which outputs "yes," or "no," if the original field contains a 1 or 0 respectively. I have this:
public function getMicrochipTextAttribute($input)
{
switch($input)
{
case 0:
return "No";
break;
case 1:
return "Yes";
break;
}
}
Unfortunately, when I use $model->microchip_text, it is returning "No," regardless of the contents of the $input. Regardless of whether $input contains a 1 or 0, it is outputting "No."