Support the ongoing development of Laravel.io →
posted 1 day ago
Eloquent
0

As far as I know, a boolean column in a migration creates a TINYINT(1) in the database, which stores 1 or 0. When you get the value from the model, it returns that raw value. To get a real boolean, you need to cast it like this:

protected function casts(): array
{
    return [
        'is_admin' => 'boolean',
    ];
}

https://laravel.com/docs/12.x/eloquent-mutators#attribute-casting

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Dani danifriki Joined 10 Feb 2026

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2026 Laravel.io - All rights reserved.