Answer the question
In order to leave comments, you need to log in
How to automatically write search query to database (Laravel)?
In Laravel I make the following requests:
Chapter::where('title', 'LIKE', $query)->paginate(10);
Section::where('title', 'LIKE', $query)->paginate(10);
...
SearchQuery::create(array(
'filter_param' => $param,
'query' => $query,
'founds' => $founds,
));
Answer the question
In order to leave comments, you need to log in
There really aren't many options:
The relationship between SearchQuery and Chapter/Section is unclear . If there is a separate SearchQuery table , then why search by Chapter/Section ?
It is also not clear when you need to create a new record, under what conditions.
Make a separate service that will manage all search queries, and, accordingly, be responsible for CRUD by $query.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question