【问题标题】:Initial migrate in laravel 5 with a reference in the ConfigServerProvider fails使用 ConfigServerProvider 中的引用在 laravel 5 中进行初始迁移失败
【发布时间】:2015-09-12 01:12:27
【问题描述】:

在启动时我的 ConfigServerProvider.php 中有对 configs 数据库表的引用。在初始迁移时,此数据库表不存在,因此出现错误。如何在第一次运行 'php artisan migrate' 的同时保持此引导行完好无损?

public function boot() {
    config([
        'version' => "1.0.2",
        'title' => Config::where('name', 'title')->first()->pluck('value')
    ]);
}

我在整个配置中添加了这个:

    if(Schema::hasTable('configs')) { }

这似乎使一切正常。

【问题讨论】:

  • 你需要编写一些代码来检查表是否存在......

标签: php laravel-5


【解决方案1】:

在我的应用中我做了这个:

try {
    $configs = Config::all();
} catch (\Exception $e) {
    $configs = [];
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-30
    • 1970-01-01
    • 2016-01-20
    • 2016-05-07
    • 2016-02-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多