1
我在我的苗條3基於應用程序中的雄辯關係有問題。目標是返回$數據來查看。當我嘗試:苗條3與雄辯ORM - 關係不存在集合
use App\Models\Favorite as F;
$favs = F::where('user_id',$_SESSION['user_id'])->get()->offer;
foreach($favs as $offer)
{
// not important now...
}
return $data;
我得到一個錯誤: 屬性[報價]不上這個集合實例存在。 我改變了我的報價關係和喜愛的車型:
public function offer() // in Favorite model
{
return $this->belongsTo('App\Models\Offer', 'offer_url');
}
public function favorite() // in Offer model
{
return $this->hasMany('App\Models\Favorite', 'url');
}
在數據庫中,我們可以看到表:報價(以URL欄)和收藏夾(與offer_url列)。
如何讓這種關係起作用?
請幫忙。