Trying to access array offset on value of type bool

A latest enterprise version with laravel 10 is not working with me.

Trying to access array offset on value of type bool

public function admin_geo_parts()

{

    $database = $this->_getDatabaseConnection();
    $config = config('grocerycrud');

    $crud = new GroceryCrud($config, $database);

    // Don't forget those two below lines if you are 
    // using CSRF protection (enabled by default on Laravel 10)
    $crud->setCsrfTokenName('_token');
    $crud->setCsrfTokenValue(csrf_token());
$crud->setTable('parts');
$crud->setSubject('Customer', 'Customers');

$output = $crud->render();

return $this->_showOutput($output);


         }

Hello @gelinger ,

That’s really weird! Can you var_dump the $output to see that we are getting the expected results?

For example:

var_dump($output);
die;

Also maybe to have the function inside a try catch? Maybe something like this?

try {
  $database = $this->_getDatabaseConnection();
    $config = config('grocerycrud');

    $crud = new GroceryCrud($config, $database);
...
$output = $crud->render();

} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}

will give a better error message?

The error is very misleading to be honest. Are you using any third-party library? Also what version of Grocery CRUD Enterprise are you using?

Regards
Johnny

Var_dump($output) will not help as the error happens on

$crud->render();

I have used this as an example

Install Grocery CRUD Enterprise in Laravel 10 | Grocery CRUD v3

[

Install Grocery CRUD Enterprise in Laravel 10 Grocery CRUD v3

Create a full stable PHP CRUD with few lines of code.


](Install Grocery CRUD Enterprise in Laravel 10 | Grocery CRUD v3)

The error happens on the ajax request to /geo-parts?action=initial

In some cases I use views (my database is postgres) and set the property $crud->setPrimaryKey, only in one case it did not work for me.
so check the model and add these lines for testing:
if (!$primaryKeyData){
$primaryKeyData = array(‘attname’ => ‘id’);
}

I make sure that the “primary key” of the views is the id field

Hello @NOLO ,

Was this setPrimaryKey worked for you or you still have issues?

Regards
Johnny

Version 2.9.6 -OK
Version 2.9.7 -Issues

Hello @NOLO ,

I am confused. I thought that you were using the latest version 3.0.19 no? Any reason that you are not using the latest version?

Regards
Johnny

Sorry Johnny, it was my fault, I just wanted to help someone else with another error that I didn’t report.

Hello @NOLO ,

I am sorry I didn’t understand. All good :slight_smile: