Reputation: 5004
Here my sql code:
SELECT favorites.id_user, specialities.specialities, university_datas.university_name
FROM
(
(
(
favorites INNER JOIN programs ON programs.id=favorites.id_program
)
INNER JOIN specialities ON programs.id_specialities=specialities.id
)
INNER JOIN university_datas ON programs.id_univer=university_datas.id
)
WHERE id_user=2;
I try with phpmyadmin and i get needed result but I can't convert to laravel
Upvotes: 2
Views: 62
Reputation: 311
$get_fav = DB::table('favorites')
->join('programs', 'favorites.id_program', '=', 'programs.id')
->join('specialities','programs.id_specialities', '=','specialities.id' )
->join('university_datas','programs.id_univer','=', 'university_datas.id')
->where('favorites.id_user', Auth::user()->id)
->select('favorites.id_user', 'specialities.specialities', 'university_datas.university_name')
->get();
Upvotes: 4