G
G
grigorie19902018-03-17 20:21:44
MySQL
grigorie1990, 2018-03-17 20:21:44

How to write a database query in Laravel that excludes the data of a related table?

Hello!
The first user table is the second post, where there is a linking column user_id, how to write a query to get all the rows from user, and skip the rows associated with another table?
THX)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
PashaNedved, 2018-03-18
@grigorie1990

$users = User::doesnthave('fuelprices')->with('fuelprices')->get();

Gets a collection of User objects along with fuelprices relationships.

G
grigorie1990, 2018-03-18
@grigorie1990

PashaNedved gave me the correct answer User::doesnthave('fuelprices')->get()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question