I have the following query in web.php which is called from use App\Models\clocks as Clock;
Route::get('/clock/{user_id}', function($user_id) {
$clocks = Clock::find($user_id);
$user = User::where('id', '=', $clocks->user_id)->first();
echo 'User: ' . $user->name . '<br />';
echo 'user_id: ' . $clocks->user_id . '<br />';
echo 'timestamp: ' . $clocks->timestamp . '<br />';
echo 'title: ' . $clocks->title . '<br />';
echo 'timer amended? ' . $clocks->timerAmended . '<br />';
echo 'description: ' . $clocks->description . '<br />';
echo 'time amended: ' . $clocks->amendedTime . '<br />';
echo 'original time: ' . $clocks->unamendedTime . '<br />';
echo 'total time: ' . $clocks->totalSeconds . '<br />';
});
I also have the following in the model
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
class clocks extends Model
{
protected $table = 'clocks';
protected $casts = [
'timerAmended' => 'boolean',
];
public function user() {
return $this->hasOne('App\Models\User');
}
}
Now, in the laravel docs, in order to output boolean as "true" or "false", a mutator is required, which I have placed in the model for timerAmended
.
However, in the view, it is still displaying as an integer. (see timer amended?
below):
User: Chauncey Walsh
user_id: 1
timestamp: 1623423462
title: Call with client
timer amended? 1
description: Strategic meeting
time amended: 120
original time: 1000
total time: 1120
Any tips on what I should do?