gpt4 book ai didi

php - 如何修复错误: SQLSTATE[42S02]: Base table or view not found: 114 6 Table 'bbs_hnq.configs' doesn't exist (SQL: select * from `configs` limit 1)

转载 作者:行者123 更新时间:2023-11-29 15:43:33 25 4
gpt4 key购买 nike

<?php

namespace App\Providers;

//use App\Models\Config;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{

\Schema::defaultStringLength(191);
$config = Config::firstOrNew(['id' => 1]);
view()->share('config', $config);
}

/**
* Register any application services.
*
* @return void
*/
public function register()
{
$this->app->singleton('settings', function () {
return Config::all();
});
}
}

最佳答案

在这里您创建表时犯了错误。您假设创建的表名称为 config

更改您的模型Config.php

class Config extends Model
{
protected $table = 'config'; //as per your table name
}

关于php - 如何修复错误: SQLSTATE[42S02]: Base table or view not found: 114 6 Table 'bbs_hnq.configs' doesn't exist (SQL: select * from `configs` limit 1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57320959/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com