belongsToManyの関係belongsToManyからデータを取得する必要があります。私のモデルのA-> B-> Cはproviders-> caption-> eventTypeなので、すべてのプロバイダをイベントタイプから取り出します。BelongsToMany BelongsToMany関係を持つ
モデルは次のようになります。
プロバイダモデル
Class Provider extends Model {
public function captions() {
return $this->belongsToMany(Caption::class);
}
}
キャプションモデル
Class Caption extend Model {
public function event_type() {
return $this->belongsToMany(Event_type::class);
}
public function providers() {
return $this->belongsToMany(Provider::class);
}
}
イベントの種類モデル
Class Event_type extends Model {
public function captions() {
return $this->belongsToMany(Caption::class);
}
}
データベースは、次のようになります。
のプロバイダ
ID
名
たevent_type
ID
名
のキャプション
名
caption_event_type
caption_id
がevent_type_id ID
caption_provider
caption_id
PROVIDER_ID
Thnks。
あなたの関係やモデルを追加してください。そうしないと、あなたを助ける方法がありません。 – martinczerwi
モデルは、パートナーSaumya Rastogiにコメントされているものと同じです。 –