B
B
BonBon Slick2017-03-22 23:08:23
MySQL
BonBon Slick, 2017-03-22 23:08:23

Laravel Query Builder checking if there is a value in the 2nd table pulling from the 1st?

$watchlist = DB::table('user_watchlist')
            ->where('user_id', $userID)
            ->orderBy('id', 'DESC')
            ->limit(4)
            ->get();

However, it also pulls out those that are already in the list. The list is another table. This request must be modified so that the id fields that are already in the watchlist list are not dragged.
Addition.
users     | users_watchlist    | course
id         id                   id
name       user_id                title
         course_id
// вытянуть все watchlist курсы юзера и отсортировать по title

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Kulik, 2017-03-24
@BonBonSlick

Either join or through models and whereHas

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question