我正在使用 laravel 5.2 版本和 PHP 7.1。我正在尝试从我的 laravel 项目中迁移文件,我有代码来检查列是否存在,如下所示 -
if (!Schema::hasColumn('table1', 'column1')) {
// Add column1
}
我知道代码非常好,并且在设置相同的代码时已经工作了好几次。但现在我在单独的机器上尝试这个并且失败并出现错误 -
[ErrorException]
未定义属性:stdClass::$column_name
如果我从代码中删除 hasColumn 检查,我可以摆脱这个错误,但这是我在整个代码中编写的内容,不能仅仅为了运行迁移而修改每个迁移。
对此的任何帮助将不胜感激。
堆栈跟踪:
[ErrorException]
未定义属性:stdClass::$column_name异常跟踪: () 在 /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php:18 Illuminate\Foundation\Bootstrap\HandleExceptions->handleError()在 /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php:18 Illuminate\Database\Query\Processors\MySqlProcessor->Illuminate\Database\Query\处理器{closure}() 在 n/a:n/a array_map() 在 /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/MySqlProcessor.php:21 Illuminate\Database\Query\Processors\MySqlProcessor->processColumnListing() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Schema/MySqlBuilder.php:40 Illuminate\Database\Schema \MySqlBuilder->getColumnListing() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:69 Illuminate\Database\Schema\Builder->hasColumn() at /private/ var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:217 Illuminate\Support\Facades\Facade::__callStatic() at /private/var/www/html/whitelabel_eb /database/migrations/2017_07_28_053158_add_columns_to_project_configurations_table.php:16 AddColumnsToProjectConfigurationsTable->{closure}() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Schema/Blueprint.php:69 Illuminate \Database\Schema\Blueprint->__construct() 在 /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:207 Illuminate\Database\Schema\Builder- >createBlueprint() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Schema/Builder.php:116 Illuminate\Database\Schema\Builder->table() at /private/ var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:217 Illuminate\Support\Facades\Facade::__callStatic() at /private/var/www/html/whitelabel_eb /database/migrations/2017_07_28_053158_add_columns_to_project_configurations_table.php:103 AddColumnsToProjectConfigurationsTable->up() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:135 Illuminate\Database \Migrations\Migrator->runUp() 在 /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:112 Illuminate\Database\Migrations\Migrator->runMigrationList() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:85 Illuminate\Database\Migrations\ Migrator->run() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:74 Illuminate\Database\Console\Migrations\MigrateCommand-> fire() at n/a:n/a call_user_func_array() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Container/Container.php:507 Illuminate\Container\Container-> call() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Console/Command.php:150 Illuminate\Console\Command->execute() at /private/var/www/ html/whitelabel_eb/vendor/symfony/console/Command/Command.php:238 Symfony\Component\Console\Command\Command->run() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Console/Command.php:136 Illuminate\Console\Command- >run() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:840 Symfony\Component\Console\Application->doRunCommand() at /private/var/www/html/whitelabel_eb /vendor/symfony/console/Application.php:190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component \Console\Application->run() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle () 在 /private/var/www/html/whitelabel_eb/artisan:353535运行()在 /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Console/Command.php:136 Illuminate\Console\Command->run() 在 /private/var/www/ html/whitelabel_eb/vendor/symfony/console/Application.php:840 Symfony\Component\Console\Application->doRunCommand() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component\Console\Application->run() at /private /var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle() at /private/var/www/html/ whitelabel_eb/工匠:35运行()在 /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Console/Command.php:136 Illuminate\Console\Command->run() 在 /private/var/www/ html/whitelabel_eb/vendor/symfony/console/Application.php:840 Symfony\Component\Console\Application->doRunCommand() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component\Console\Application->run() at /private /var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle() at /private/var/www/html/ whitelabel_eb/工匠:353535run() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:840 Symfony\Component\Console\Application->doRunCommand() at /private/var/www/html/whitelabel_eb/供应商/symfony/console/Application.php:190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component\ Console\Application->run() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle( ) 在 /private/var/www/html/whitelabel_eb/artisan:35run() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:840 Symfony\Component\Console\Application->doRunCommand() at /private/var/www/html/whitelabel_eb/供应商/symfony/console/Application.php:190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component\ Console\Application->run() at /private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle( ) 在 /private/var/www/html/whitelabel_eb/artisan:35190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component\Console\Application->run() at / private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle() at /private/var/www/html /whitelabel_eb/工匠:35190 Symfony\Component\Console\Application->doRun() at /private/var/www/html/whitelabel_eb/vendor/symfony/console/Application.php:114 Symfony\Component\Console\Application->run() at / private/var/www/html/whitelabel_eb/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:107 Illuminate\Foundation\Console\Kernel->handle() at /private/var/www/html /whitelabel_eb/工匠:35