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

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

在 laravel 5.8 中進(jìn)行方法調(diào)用時(shí),它不會(huì)向我返回?cái)?shù)據(jù)

在 laravel 5.8 中進(jìn)行方法調(diào)用時(shí),它不會(huì)向我返回?cái)?shù)據(jù)

PHP
繁星淼淼 2022-01-02 19:33:45
根據(jù) Laravel 的文檔在我創(chuàng)建的模型中創(chuàng)建關(guān)系時(shí)出現(xiàn)了我的問(wèn)題。我有我的區(qū)號(hào)表和我的電話表,一個(gè)區(qū)號(hào)可以屬于多部電話,但一部電話只有一個(gè)區(qū)號(hào),這使我成為一對(duì)多的關(guān)系我將向您展示我的模型和它們之間的關(guān)系。電話.php/** * The table associated with the model. *  * @var string * @author Luis Morales */protected $table = 'PHONES';/** * The primary key associated with the table. * * @var string * @author Luis Morales */protected $primaryKey = 'PHONES_ID';/** * The attributes that are mass assignable. * * @var array * @author Luis Morales */protected $fillable = [    'AREACODES_ID', 'PHONE', 'DATE', 'USERS_ID',];/** * Indicates if the model should be timestamped. * * @var bool * @author Luis Morales */public $timestamps = false;/** * Get the user for the phone *  * @author Luis Morales */public function users(){    return $this->belongsTo('App\User');}/** * Get the area code for the phone *  * @author Luis Morales */public function areacodes(){    return $this->belongsTo('App\AreaCode');}   區(qū)號(hào).php/** * The table associated with the model. *  * @var string * @author Luis Morales */protected $table = 'AREACODES';/** * The primary key associated with the table. * * @var string * @author Luis Morales */protected $primaryKey = 'AREACODES_ID';/** * The attributes that are mass assignable. * * @var array * @author Luis Morales */protected $fillable = [    'CODE', 'CITY', 'STATESZONE_ID',];/** * Indicates if the model should be timestamped. * * @var bool * @author Luis Morales */public $timestamps = false;/** * Get the phone for the area codes * * @author Luis Morales */public function phones(){    return $this->hasMany('App\Phone');}在我的控制器中,調(diào)用如下GenerateNumbersController.php$phones = Phone::where('DATE',$searchOrCreate)                ->chunk(500,function($phone){                        foreach ($phone as $p) {                        dd($p->areacodes);                    }        });searchOrCreate 變量有一個(gè)日期格式的值,我對(duì) $ phone 做了一個(gè) dd 并且它顯示的所有關(guān)系都是空的
查看完整描述

2 回答

?
慕沐林林

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

你調(diào)用了錯(cuò)誤的方法。dd($p->區(qū)號(hào)); 因?yàn)樵谀氖謾C(jī)型號(hào)中,您的型號(hào)名稱是與您調(diào)用的功能不匹配的區(qū)號(hào)。解決方案更改 dd($p->areacode);dd($p->areacodes);


查看完整回答
反對(duì) 回復(fù) 2022-01-02
?
猛跑小豬

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

更改您的 return 語(yǔ)句以 return $this->belongsTo( 'App\AreaCode', 'AREACODES_ID', 'PHONES_ID');


查看完整回答
反對(duì) 回復(fù) 2022-01-02
  • 2 回答
  • 0 關(guān)注
  • 162 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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