T
T
Troodi Larson2019-01-19 18:28:55
Laravel
Troodi Larson, 2019-01-19 18:28:55

Linking tables, Laravel models, to select non-repeating elements?

Good day. I read it, but I don’t quite understand how to make such a scheme correctly.
There are 2 tables. (ID, NAME)
The attributes are the same. It is necessary to select only those elements that are not in the second table.
It can be done through the DB class, but it would be more correct through Eloquent, and I don’t quite understand how to link it.
Is it appropriate to use $this->belongsTo. I read about the relations themselves, but did not understand how to select non-repeating fields.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Evgrafovich, 2019-01-19
@troodi

It through join the request becomes. Type in mysql join in Yandex and go to the pictures section, there are a lot of diagrams showing how to write such a query.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question