Answer the question
In order to leave comments, you need to log in
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
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 questionAsk a Question
731 491 924 answers to any question