2

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

2
  • Wait. what? Your question is unclear. SQL is a programming language. laravel is a framwork. Do you mean how you perform sql-request in the laravel framework? Commented Jan 26, 2018 at 6:12
  • 1
    Have you tried anything? If yes, show us. If no, read the manual and make some attempts. Commented Jan 26, 2018 at 6:17

1 Answer 1

4
$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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.