J
J
Jedi2020-05-21 12:39:22
Laravel
Jedi, 2020-05-21 12:39:22

How to stop repeating entries?

Help write the code. I looked in the documentation and didn't find anything suitable.

There is Cars - cars and UserCars - where we keep records of how many times and who bought cars.

With one-to-many I can get all the records I need.
Each user can buy the same car many times. Since these machines are sold for a certain period of time. I want to know how many users this machine has been sold to. But I can get a completely different figure, since there can be several entries from one user. Can you please tell me how to make a request?

return $this->hasMany('App\UserCars');



Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question