php - Laravel query, foreach function to remove items then paginate -


a user searches profiles within km radius i.e. 50 km of run function uses latitude/longitude values retrieve results (this rough search within square not straight line distance), paginate results.

$query = $this->filternearby($query, $geocode); $query = $query->paginate(10);

but each query need run proper distance using great circle formula (to accurate 50km) , people searched may willing travel 20km location need remove these query.

i have tried $query = $query->get() prior pagination, each remove items pagination not work. have tried create new paginator unsure how works through view?

latest code:

if (\request::segment(2) == "jobs")             {                                    $query = $this->searchjob($search_strategy);                 $query = $this->filternearbyjob($query, $geocode);                 $query = $this->filterjob($query);                  $query = $query->get();                  // foreach function go here accurate distance between 2 points , remove query results                  $paginate = new paginator($query, count($query), 10);                    $category = $this->getcategoryurl($search_strategy);                                 $sub_categories = servicesubcategory::where('sub_category_url', '=', $search_strategy)->first();                  return view('search.job')                     ->with('category', $category)                     ->with('sub_categories', $sub_categories)                     ->with('search_results', $paginate);                 } 

you cannot call get prior paginate, matter of fact, can call 1 of them. should filter database query or consider making instance of illuminate\pagination\paginator or illuminate\pagination\lengthawarepaginator


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -