Недавно я добавил 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 и обнаружил 1 проблему, но даже после ее исправления с помощью редактора таблиц проблема все еще сохраняется.
Вот трассировка стека
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 и ожидал, что он приведет меня к пользовательскому интерфейсу, чтобы добавить ХЛЕБ в таблицу.
Обновлено: Вот код из 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(...
Мне удалось решить проблему, выполнив несколько действий, поэтому я не совсем уверен, что именно было решено, но я сделал следующее:
1- Добавлены ограничения внешнего ключа, которые я забыл добавить, а затем сделал резервную копию моего проекта.
2- Удалите voyager, следуя инструкциям по этой ссылке здесь.
3- Понизьте мою установку laravel с версии 10.0 до версии 9.0, так как voyager в настоящее время поддерживает только версии 8 и 9 в соответствии с документацией .
4- Переустановите Вояджер.
Если бы я предположил, я бы сказал, что это комбинация ошибочной установки + несовместимость версии.