php 无法在Laravel Voyager中编辑或创建BREAD(参数#5($fk约束)必须是数组类型,bool给定)

f87krz0w  于 2023-05-05  发布在  PHP
关注(0)|答案(1)|浏览(126)

我最近将Voyager添加到一个小的Laravel项目中,我一直在使用文档中的指南。一切正常,但每当我点击“编辑面包”或“添加面包到这个表”在数据库部分,我遇到以下错误

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

我在MySql workbench中检查了外键约束,发现了一个问题,但即使使用表编辑器修复了它,问题仍然存在。
下面是堆栈跟踪

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)

我点击Voyager中的“编辑面包”或“将面包添加到此表”按钮,我期望它会带我到UI将面包添加到表中。
编辑:这是Voyager BreadController的代码,例如,编辑BREAD(创建时也会发生同样的问题)

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'));
    }

突出显示的行是以下$fieldOptions = SchemaManager::describeTable(...

xuo3flqw

xuo3flqw1#

我通过做几件事来解决这个问题,所以我不确定是哪一件解决了这个问题,但我做了如下事情:
1-添加了一个我忘记添加的外键约束,然后备份了我的项目。
2-按照link here中的步骤卸载voyager。
3-把我的laravel安装从10.0版降级到9.0版,因为voyager目前只支持documentation版本8和9。
4-重新安装航行者号。
如果让我猜的话,我会说这是错误安装+版本不兼容的组合。

相关问题