Answer the question
In order to leave comments, you need to log in
How to make a Laravel fetch?
Hello!
I can't solve this problem:
There are 4 tables: User, Categories, category_user, Tender
User, Categories I linked many to many.
I need to display tenders depending on which category the user has, before, when one category could be selected and not several, I did it like this:
$user = User::find($id);
return Tender::where('published_at', '<', Carbon::now())
->where('date_end', '>', Carbon::now())
->where('category', $user->category)
->where('status', true)
->with(['rates'])
->orderBy('id', 'DESC')
->get();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question