Level 18
The best way? Use a relationship and a model.
Otherwise you are just doing all the work that has already been done...
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
my query
$data = DB::table('countries')
->leftJoin('matches', function ($join) {
$join->on('matches.hometeam', '=', 'countries.id')
->orOn('matches.awayteam', '=' ,'countries.id');
})
->where('countries.id', $id)->get();
return dd($data);
how i can get same results use relationship
Please or to participate in this conversation.