skip to Main Content

how to make relationship between to table in laravel?

my database has two table games and teams, games migration: $table->unsignedBigInteger('homeTeam'); $table->unsignedBigInteger('awayTeam'); $table->foreign('homeTeam')->references('id')->on('teams') $table->foreign('awayTeam')->references('id')->on('teams') what is relationship between this two table? many to many? should I create "game_team" pivot table? i tried to change design of database but it don't…

VIEW QUESTION

Laravel 10 relation dynamic variable in subquery

How can I call a dynamic variable in a subquery? I have some relations and call them like: $locations = Location::query() ->with('brands', function ($query) { $query->with('employees')->where('location_id', {dynamic ID of brand location}); }) ->get(); The relation in the Location.php Class: public…

VIEW QUESTION
Back To Top
Search