phplaravelvoyager

Can't edit or create BREAD in Laravel Voyager (Argument #5 ($fk Constraints) must be of type array, bool given)


I recently added Voyager onto a small Laravel project I have been working on using the documentation's guide on how to do so. Everything worked fine but whenever I click "Edit BREAD" or "Add BREAD to this table" in the databases section I encounter the following error

Doctrine\DBAL\Schema\Table::__construct(): Argument #5 ($fkConstraints) must be of type array, bool given, called in C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\tcg\voyager\src\Database\Schema\SchemaManager.php on line 65

I checked my foreign key constraints in MySql workbench and found 1 issue but even after fixing it using the table editor the issue still persists.

Here is the stack trace

TypeError:
Doctrine\DBAL\Schema\Table::__construct(): Argument #5 ($fkConstraints) must be of type array, bool given, called in C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\tcg\voyager\src\Database\Schema\SchemaManager.php on line 65

  at C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\doctrine\dbal\src\Schema\Table.php:62
  at Doctrine\DBAL\Schema\Table->__construct()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\tcg\voyager\src\Database\Schema\SchemaManager.php:65)
  at TCG\Voyager\Database\Schema\SchemaManager::listTableDetails()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\tcg\voyager\src\Database\Schema\SchemaManager.php:79)
  at TCG\Voyager\Database\Schema\SchemaManager::describeTable()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\tcg\voyager\src\Http\Controllers\VoyagerBreadController.php:125)
  at TCG\Voyager\Http\Controllers\VoyagerBreadController->edit()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Routing\Controller.php:54)
  at Illuminate\Routing\Controller->callAction()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Routing\ControllerDispatcher.php:43)
  at Illuminate\Routing\ControllerDispatcher->dispatch()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Routing\Route.php:259)
  at Illuminate\Routing\Route->runController()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Routing\Route.php:205)
  at Illuminate\Routing\Route->run()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Routing\Router.php:798)
  at Illuminate\Routing\Router->Illuminate\Routing\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:141)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\tcg\voyager\src\Http\Middleware\VoyagerAdminMiddleware.php:26)
  at TCG\Voyager\Http\Middleware\VoyagerAdminMiddleware->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Routing\Middleware\SubstituteBindings.php:50)
  at Illuminate\Routing\Middleware\SubstituteBindings->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php:78)
  at Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\View\Middleware\ShareErrorsFromSession.php:49)
  at Illuminate\View\Middleware\ShareErrorsFromSession->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php:121)
  at Illuminate\Session\Middleware\StartSession->handleStatefulRequest()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Session\Middleware\StartSession.php:64)
  at Illuminate\Session\Middleware\StartSession->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse.php:37)
  at Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Cookie\Middleware\EncryptCookies.php:67)
  at Illuminate\Cookie\Middleware\EncryptCookies->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:116)
  at Illuminate\Pipeline\Pipeline->then()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Routing\Router.php:797)
  at Illuminate\Routing\Router->runRouteWithinStack()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Routing\Router.php:776)
  at Illuminate\Routing\Router->runRoute()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Routing\Router.php:740)
  at Illuminate\Routing\Router->dispatchToRoute()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Routing\Router.php:729)
  at Illuminate\Routing\Router->dispatch()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:200)
  at Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:141)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:21)
  at Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull.php:31)
  at Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TransformsRequest.php:21)
  at Illuminate\Foundation\Http\Middleware\TransformsRequest->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\TrimStrings.php:40)
  at Illuminate\Foundation\Http\Middleware\TrimStrings->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\ValidatePostSize.php:27)
  at Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance.php:86)
  at Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Http\Middleware\HandleCors.php:49)
  at Illuminate\Http\Middleware\HandleCors->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Http\Middleware\TrustProxies.php:39)
  at Illuminate\Http\Middleware\TrustProxies->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:180)
  at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Pipeline\Pipeline.php:116)
  at Illuminate\Pipeline\Pipeline->then()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:175)
  at Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php:144)
  at Illuminate\Foundation\Http\Kernel->handle()
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\public\index.php:51)
  at require_once('C:\\Users\\Haytham\\Desktop\\Cafe21 Ionic-Angular\\Cafe21\\API\\public\\index.php')
     (C:\Users\Haytham\Desktop\Cafe21 Ionic-Angular\Cafe21\API\vendor\laravel\framework\src\Illuminate\Foundation\resources\server.php:16)  

I clicked on the "Edit BREAD" or "Add BREAD to this table" buttons in Voyager and I expected it to take me to the UI to add BREAD to the table.

EDIT: Here is the code from the Voyager BreadController related to editing BREAD for example (same issue happens with creating)

public function edit($table)
    {
        $this->authorize('browse_bread');

        $dataType = Voyager::model('DataType')->whereName($table)->first();

        $fieldOptions = SchemaManager::describeTable(
            (strlen($dataType->model_name) != 0)
            ? DB::getTablePrefix().app($dataType->model_name)->getTable()
            : DB::getTablePrefix().$dataType->name
        );

        $isModelTranslatable = is_bread_translatable($dataType);
        $tables = SchemaManager::listTableNames();
        $dataTypeRelationships = Voyager::model('DataRow')->where('data_type_id', '=', $dataType->id)->where('type', '=', 'relationship')->get();
        $scopes = [];
        if ($dataType->model_name != '') {
            $scopes = $this->getModelScopes($dataType->model_name);
        }

        return Voyager::view('voyager::tools.bread.edit-add', compact('dataType', 'fieldOptions', 'isModelTranslatable', 'tables', 'dataTypeRelationships', 'scopes'));
    }

The highlighted line is the following $fieldOptions = SchemaManager::describeTable(...


Solution

  • I managed to solve the issue by doing a couple of things so I am not really sure which one it was that solved but what I did was as follows:

    1- Added a foreign key constraints that I had forgotten to add and then backed up my project.

    2- Uninstall voyager following the steps in this link here.

    3- Downgrade my laravel installation from version 10.0 to version 9.0 as voyager currently only supports version 8 and 9 according to the documentation.

    4- Reinstall voyager.

    If I were to guess I would say its a combination of a faulty install + version incompatibility.