Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TheRabber's avatar

Can't update boolean when defined as a property

Hey, I have a vehicle model and resource in my laravel/nova application with a boolean called in_service. In my migration it's defined like this:

$table->boolean('in_service');

In my model I added it as a property and to the fillable array like this:

public bool $in_service;

protected $fillable = [
		'in_service'
]

and using it in the resource like this:

Boolean::make(__('InService'), 'in_service'),

now my problem is that nova won't update the value of the bool as soon as I define it as a property on the model. It works with all other defined properties, but not with the bool one. Does anyone know why? I already tried casting or removing the typing, still, as long as it's defined it won't work.

0 likes
4 replies
s4muel's avatar

do you need to be defined as a property on the model? laravel does some auto-casting of boolean values to integer 0/1 when inserting to/getting from database. not sure, but this might be the case when hard-set to bool type. does it work when you omit the type?

public $in_service;
TheRabber's avatar

@s4muel I want to access that property and without declaring it, it would be magic access, ok, but not sooo nice.

Sadly omitting the type doesn’t work, as long as it’s defined, it‘s causing the problem.

I guess for now I stick with the magic

1 like
s4muel's avatar

@TheRabber i get your point and i have no intent to oppose... but do you really declare all of the model properties? i think this is exactly that kind of "magic" that all laravel developers enjoy the most;) in case of developer experience (IDE auto-completion, code navigation and phpstan), i would just stick to ide-helper tool which inspects the database and add phpdocs for all properties automatically (https://github.com/barryvdh/laravel-ide-helper?tab=readme-ov-file#automatic-phpdocs-for-models)

krisi_gjika's avatar

I don't think declaring DB fields as properties works in general, as these fields would not be filled with the values from the DB.

Please or to participate in this conversation.