亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我的遷移文件在運行“php artisan migrate”時出現錯誤

我的遷移文件在運行“php artisan migrate”時出現錯誤

PHP
達令說 2023-04-02 14:54:28
我得到的錯誤是“Illuminate\Database\QueryException:SQLSTATE[42S22]:未找到列:1054 ‘where 子句’中的未知列‘key’(SQL:從其中選擇 *!=admin_settings空key限制 1)”因為函數在app/Providers/AppServiceProvider.php public function boot()    {        if (Schema::hasTable('admin_settings')) {            $google_analytics_details = AdminSetting::where('key','!=','null')->first();        }else {            $google_analytics_details = '';        }                View::share('google_analytics_details', $google_analytics_details);    }當我評論引導功能的代碼時,它就成功遷移了。我正在尋找此視圖共享的替代方案。誰能幫我??我的遷移文件內容:<?phpuse Illuminate\Database\Migrations\Migration;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;class UpdateAdminSettingsTable extends Migration{    /**     * Run the migrations.     *     * @return void     */    public function up()    {        //         Schema::table('admin_settings', function (Blueprint $table) {            $table->dropColumn('google_analytics_code');        });        Schema::table('admin_settings', function (Blueprint $table) {            $table->longText('key')->nullable()->after('id');            $table->longText('value')->nullable()->after('key');        });    }    /**     * Reverse the migrations.     *     * @return void     */    public function down()    {        //         Schema::table('admin_settings', function (Blueprint $table) {        });    }}
查看完整描述

1 回答

?
ABOUTYOU

TA貢獻1812條經驗 獲得超5個贊

如果您想將變量共享到一個視圖(可以加載或擴展到其他視圖,例如layout.app),您可以指定視圖名稱,如下例所示

簡單的例子:

View::composer('view-name', function ($view) {

? ? ? ? ? ? ?$view->with('key', 'value');

? ? ? ? });

或者如果您在所有視圖中都需要它,您可以*像這樣用作視圖名稱


View::composer('*', function ($view) {

? ? ? ? ? ? ?$view->with('key', 'value');

? ? ? ? });

另一種解決問題的方法

您的遷移問題也可以在共享視圖之前通過條件解決


?public function boot()

? ? {

? ? ? ? if ( !app()->runningInConsole() ){

? ? ? ? ? ? ?// your code here

? ? ? ? }

? ? }


查看完整回答
反對 回復 2023-04-02
  • 1 回答
  • 0 關注
  • 183 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號