Answer the question
In order to leave comments, you need to log in
Relationships in Laravel. How to be?
Is it possible to implement communication in the context of one model. Suppose there is a Game model and the platforms table needs to organize a many-to-many relationship, how can you place the platforms array in the model property of the same name without creating the Platforms model.
Answer the question
In order to leave comments, you need to log in
You can do something like this:
public function platforms() {
return DB::table('game_platforms')
->join('platforms', 'platforms.id', '=', 'game_platforms.platform_id')
->where('game_platforms.game_id', '=', $this->id)
->get();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question