Search
 
SCRIPT & CODE EXAMPLE
 

SQL

laravel paginate raw sql

$items = DB::table('team')   
    ->selectRaw('SELECT *,earth_distance(ll_to_earth(team.lat, team.lng), ll_to_earth(23.1215939329,113.3096030895)) AS distance')
    ->whereRaw('earth_box(ll_to_earth(23.1215939329,113.3096030895),1000) @> ll_to_earth(team.lat, team.lng)')
    ->paginate(10);

foreach($items as $item) {
    echo $item->distance;
}
Comment

laravel pagination having raw query not working

        $curPage = IlluminatePaginationPaginator::resolveCurrentPage();
        $total = $model->get()->count();
        $items = $model->forPage($curPage, $showPerPag)->get();
        $paginated = new IlluminatePaginationLengthAwarePaginator($items, $total, $showPerPage, $curPage, ['path' => request()->url(), 'query' => request()->query()]);
Comment

laravel pagination having raw query not working

// This works as expected       

		$curPage = IlluminatePaginationPaginator::resolveCurrentPage();
        $total = $model->get()->count();
        $items = $model->forPage($curPage, $showPerPag)->get();
        $paginated = new IlluminatePaginationLengthAwarePaginator($items, $total, $showPerPage, $curPage, ['path' => request()->url(), 'query' => request()->query()]);
Comment

PREVIOUS NEXT
Code Example
Sql :: postgresql add alter permissions to role 
Sql :: mysql find and replace 
Sql :: how to get weekday from old date in sql 
Sql :: oracle add month 
Sql :: group concat with separator 
Sql :: select from array in psql 
Sql :: delete table sql 
Sql :: mysql update table from select on another table 
Sql :: FIND OUT THE NAME HIGHEST SALARY SQL 
Sql :: set auto increment from 1 
Sql :: sql insert timestamp 
Sql :: get first 3 letters name in sql 
Sql :: select first rows postgresql 
Sql :: sql cast to integer 
Sql :: run mysql xampp shell 
Sql :: show all public tables postgres 
Sql :: how to check schema privileges in oracle 
Sql :: installing postgresql ubuntu 
Sql :: sql server cannot create database diagram 
Sql :: oracle sql group by date year 
Sql :: mysql python 
Sql :: oracle sessions_per_user limit 
Sql :: mysql remote connection command line 
Sql :: purge undo tablespace oracle 11g 
Sql :: xml path sql server 
Sql :: get ip from phpmyadmin 
Sql :: oracle all source 
Sql :: SET NOCOUNT ON; 
Sql :: delete top N rows in sql 
Sql :: mysql select if empty result 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =