Closed youkoulayley closed 5 years ago
Hi,
I have these tables :
shows :
seasons :
episodes :
My model Episode is like this :
/** * @return \Znck\Eloquent\Relations\BelongsToThrough */ public function show() { return $this->belongsToThrough(Show::class, Season::class); } /** * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function season() { return $this->belongsTo('App\Models\Season'); }
This works fine, but when I want to get only one column with belongs to through, it's doesn't work. I have tried this :
$this->episode ->whereId($episode_id) ->with(['season:seasons.id', 'show' => function ($q) { $q->select('shows.id'); }]) ->select('episodes.id', 'episodes.season_id') ->get()
Or this :
$this->episode ->whereId($episode_id) ->with('season:seasons.id', 'show:shows.id') ->select('episodes.id', 'episodes.season_id') ->get()
Season work fine but shows send me this : https://i.imgur.com/0M5q0vE.png
It's not that bad, but I want to know if it's normal or if i missed something.
Thanks in advance !
Hi,
I have these tables :
shows :
seasons :
episodes :
My model Episode is like this :
This works fine, but when I want to get only one column with belongs to through, it's doesn't work. I have tried this :
Or this :
Season work fine but shows send me this : https://i.imgur.com/0M5q0vE.png
It's not that bad, but I want to know if it's normal or if i missed something.
Thanks in advance !