in my Laravel app I have 3 tables : users, documents and type_documents, the user have multiple documents and document have one type_document
| Documents |
| -------- |
| id |
| file |
| type_document_id|
| user_id |
| type_documents |
| -------- |
| id |
| name |
| users |
| -------- |
| id |
| name |
| type_document_d|
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 :
$document_types = TypeDocument::leftJoin('docments' , function ($join) {
$join->on('type_documents.id', '=', 'douments.type_document_id')
->where('documents.user_id', auth()->id());
})
->applyFilters($request->all())
->latest()
->paginateData($limit);
I use Laravel version 8