I'm trying to use Laravel 5.1 manual paging because I have a query that needs to be written with DB's select, but paging does not work! It returns me all the data on the screen without paging.
Follows:
use Illuminate\Pagination\LengthAwarePaginator as Paginator;
$my_query = DB::select('
;WITH
UL1 As (SELECT E.ClientStoreID, MAX(E.InsertDate) AS data
FROM ClientStoreMediaExecuted AS E, ClientStore AS S
WHERE E.ClientStoreID = E.ClientStoreID
AND S.ClientID=?
GROUP BY E.ClientStoreID)
SELECT CS.* FROM UL1 RIGHT OUTER JOIN ClientStore AS CS
ON (CS.ClientStoreID = UL1.ClientStoreID)
WHERE CS.ClientID=?
AND CS.IsActive=1', [$id, $id]);
$paginator = new Paginator($my_query, count($my_query), $perPage, $currentPage, [
'path' => Request::path(),
'query' => $my_query,
'fragment' => array_slice($my_query, $perPage),
'pageName' => 'page'
]);