0

I filter job offers on data from a database. As long as the table contained up to 10,000 records, everything worked great.

$searchQuery = \App\JobOffers::searchOffer($search_text, $search_location, $job_function, $job_type, $job_experience, $date_filter, $last);

Now the table has over 60,000 records with job offers. When I wants to perform filtering, the application returns error 500.

I can't find a solution to this problem.

I thought about using 'chunk'. I don't know if this solution will help.

foreach ($all->chunk(100) as $key => $chunk) {
    $chunk = $chunk->all();

    $test = $chunk::searchOffer($search_text, $search_location, $job_function, $job_type, $job_experience, $date_filter, $last);
    $searchQuery->push($test);
}

In the above example I get an error: "Class name must be a valid object or a string".

Is there any way to solve this problem?

  • 1
    You can't use `::searchOffer` (static methods) in a variable. That's the first problem I see there. It must be a class or namespace. Have you thought about doing a raw SQL query to the database with your custom restraints? – gd_silva Jan 02 '19 at 14:42
  • Of course you can bind a `function()` to a `$variable`. If your using `Laravel Scout`, you forgotten to `->get()` to the end of `$searchQuery` – Anuga Jan 02 '19 at 14:49

0 Answers0