Я хочу получить фотографии взаимоотношений модели Pivot
class WeedHasState extends Pivot
{
protected $table = 'weed_has_state';
protected $fillable =['weed_id','weed_state_id','id'];
public function weed()
{
return $this->belongsTo(Weed::class, 'weed_id');
}
public function state()
{
return $this->belongsTo(WeedState::class);
}
public function photos(){
return $this->hasMany(WeedPhoto::class);
}
}
Модель, которая вызывает модель Pivot, выглядит так:
class Weed extends BaseModel
{
public function states()
{
return $this->belongsToMany(WeedState::class, 'weed_has_state', 'weed_id', 'weed_state_id')
->using(WeedHasState::class)
->withPivot('weed_id', 'weed_state_id')
->withTimestamps();
}
}
Вызов withPivot('weed_id','weed_state_id','photos')
не работает, ни одна идея