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

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

如何解決 Laravel 查詢中的空返回?

如何解決 Laravel 查詢中的空返回?

PHP
梵蒂岡之花 2022-12-23 15:34:12
鑒于我的模型Person和Student. 現(xiàn)在,我的一個(gè)控制器正在這樣做:$person_id = \App\Models\Person::insertGetId(['name' => $request->name, ...]);\App\Models\Student::create(['person_id' => $person_id, ...]);$student = \App\Models\Student::where('person_id', $person_id)->first();dd($student);在執(zhí)行期間,一切都已保存,但我的問題是為什么我在死亡和轉(zhuǎn)儲(chǔ)時(shí)收到空值?順便說一下,我的student表primary和foreign鍵是person_id列。編輯class Student extends Model{    protected $fillable = ['section', 'current_year'];//there are other attribute here which I didn't show because I am using mobile    public function person(){       return $this->belongsTo('App\Models\Person', 'person_id', 'id');    }    ...}
查看完整描述

1 回答

?
HUH函數(shù)

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

添加person_id屬性$fillable

protected $fillable = ['section', 'current_year', 'person_id'];


查看完整回答
反對(duì) 回復(fù) 2022-12-23
  • 1 回答
  • 0 關(guān)注
  • 110 瀏覽

添加回答

舉報(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)