第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

我應(yīng)該使用不同的表為我的遷移制作多個(gè)模型嗎

我應(yīng)該使用不同的表為我的遷移制作多個(gè)模型嗎

PHP
慕無忌1623718 2021-07-13 17:41:54
我有一個(gè)包含多個(gè)表的遷移:Status、Status_project、Status_task。我可以僅使用使用遷移命令創(chuàng)建的狀態(tài)模型來調(diào)用它們嗎?php artisan make:model 狀態(tài) -m我在幾個(gè)地方讀到我必須為每張桌子制作一個(gè)模型,但沒有其他方法嗎?除了 DB::table('statuses')。由于我的關(guān)系,我不喜歡多個(gè)模型例子: Schema::create('statuses', function (Blueprint $table) {        $table->bigIncrements('id');        $table->string('name')->unique();        $table->string('display_name')->nullable();        $table->string('description')->nullable();        $table->timestamps();    });    Schema::create('status_task', function (Blueprint $table) {        $table->bigIncrements('id');        $table->string('user_id')->nullable();        $table->unsignedBigInteger('task_id');        $table->unsignedBigInteger('status_id');        $table->foreign('user_id')->references('id')->on('users')            ->onUpdate('cascade')->onDelete('cascade');        $table->foreign('task_id')->references('id')->on('ongoing_tasks')            ->onUpdate('cascade')->onDelete('cascade');        $table->foreign('status_id')->references('id')->on('statuses')            ->onUpdate('cascade')->onDelete('cascade');    });    Schema::create('status_project', function (Blueprint $table) {        $table->bigIncrements('id');        $table->string('user_id')->nullable();        $table->string('project_id');        $table->unsignedBigInteger('status_id');        $table->foreign('user_id')->references('id')->on('users')            ->onUpdate('cascade')->onDelete('cascade');        $table->foreign('project_id')->references('id')->on('ongoing_projects')            ->onUpdate('cascade')->onDelete('cascade');        $table->foreign('status_id')->references('id')->on('statuses')            ->onUpdate('cascade')->onDelete('cascade');    });    DB::commit();
查看完整描述

1 回答

?
搖曳的薔薇

TA貢獻(xiàn)1793條經(jīng)驗(yàn) 獲得超6個(gè)贊

如果您計(jì)劃使用 Eloquent 構(gòu)建查詢,則需要為每個(gè)表創(chuàng)建一個(gè)模型。如果您使用的是查詢構(gòu)建器,則無需為每個(gè)表創(chuàng)建模型。


查看完整回答
反對(duì) 回復(fù) 2021-07-16
  • 1 回答
  • 0 關(guān)注
  • 185 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)