M
M
mynewvk2017-06-22 11:55:27
Laravel
mynewvk, 2017-06-22 11:55:27

How to search in laravel?

Good afternoon! Please advise the best solution. Task: there are two models, let A and B, they have common categories, half of the fields. There is a search form where you can select a date (from, to), category, type (A or B) and city. So, how to do without a bunch of conditions, if you need to display for all cities, if the city is not set, for all categories, if the categories are not set, combine two models, if the type is not set, and so on. Thank you!
UPD: I found a good article, maybe someone is interested - https://m.dotdev.co/writing-advanced-eloquent-sear...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Pushkarev, 2017-06-22
@AXP-dev

Make a common controller. Pass a form into it, validate it, and then get data from one model or two

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question