Skip to content
Advertisement

how join laravel tables to get non intersected data

in my Laravel app I have 3 tables : users, documents and type_documents, the user have multiple documents and document have one type_document

I want select the types that are not used in documents table for the current user with eloquent
I try with this, but it give me the used type_documents :

I use Laravel version 8

Advertisement

Answer

Have you tried whereNotExists() or whereNotIn() instead of leftJoin()?

eg:

try any of these!

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement