Laravel Upgrade to PHP 8.1: Attribute value must be of type bool for selected attribute, array given: Laravel Upgrade to PHP 8.1

When upgrading Laravel to PHP 8.1, you could receive the following notice:

Attribute value must be of type bool for selected attribute, array given

The reason:

This should likely be in your theme or Eloquent code. Try adding a new simple temporary route in routes/web.php:

Route::get('/test', function() { return "hi"; });

When opening /test it should probably be working.

That is why it could be something in your theme. Navigate to your blade theme.

Strangely enough, this already seems to be happening before the blade theme when we are doing an Eloquent request, like:

Route::get('/test', function() { return Page::all(); });

Strangely enough, using Laravel 9 with PHP 8.0 instead of PHP 8.1 seems to remove the error.

Problem solved

It seemed that in the config/database.php there were wrong settings in the mysql driver:

'options' => [\PDO::ATTR_EMULATE_PREPARES => true + extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),

When changing this to:

'options' => extension_loaded('pdo_mysql') ? array_filter([
                PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
            ]) : [],

It gets resolved

Does anybody have had this problem as well and know how to fix this?

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top