英文:
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
<details>
<summary>英文:</summary>
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(...`
</details>
# 答案1
**得分**: 0
1- 我通过添加了我之前忘记添加的外键约束以及备份项目来解决了这个问题。
2- 按照这个[链接][1]中的步骤卸载了Voyager。
3- 将我的Laravel安装从版本10.0降级到了版本9.0,因为根据[文档][2],Voyager目前仅支持版本8和9。
4- 重新安装了Voyager。
如果我要猜的话,我会说这是安装错误和版本不兼容的组合。
[1]: https://stackoverflow.com/questions/58124293/how-to-safely-uninstall-voyager-in-laravel
[2]: https://voyager-docs.devdojo.com/getting-started/prerequisites
<details>
<summary>英文:</summary>
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 [1].
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][2].
4- Reinstall voyager.
If I were to guess I would say its a combination of a faulty install + version incompatibility.
[1]: https://stackoverflow.com/questions/58124293/how-to-safely-uninstall-voyager-in-laravel
[2]: https://voyager-docs.devdojo.com/getting-started/prerequisites
</details>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论