How to convert raw query into Laravel Eloquent way -
i have raw query. how can convert 1 laravel eloquent.
select * `results` q inner join `answers`as on q.question_id = a.question_id , q.team1 = a.team1 , q.team2 = a.team2 , q.score1 = a.score1 // table relationships. results hasmany answers. results hasmany predictions. prediction model here.
as far understood question,you can't relationship joins.
please try query.
result::join('results q', function ($join) { $join->on('answers.question_id', '=', 'q.question_id') ->on('user_answers.team1', '=', 'q.team1') ->on('user_answers.team2', '=', 'q.team2') ->on('user_answers.score1', '=', 'q.score1') ->on('user_answers.score2', '=', 'q.score2'); })->get();
now can run query relational data.
Comments
Post a Comment