Returning always true in laravel user model for positive integer
class User extends .....
{
protected $casts = [
'email_verified_at' => 'datetime',
'enabled' => 'boolean',
];
public function isEnabled(): bool
{
return $this->enabled == 1 ? true : false;
}
}
in MySQL Table
enabled is tinyint unsigned
in controller
$user->isEnabled() //Returning always true in laravel user model for positive integer
>Solution :
You have set enabled
feld as tinyint and you have said true for all positve integer ; so rewrite as below
protected $casts = [
'email_verified_at' => 'datetime',
'enabled' => 'boolean', // remove this line as you casting enabled as boolen which returns true on positive integer
];