2016-09-17 113 views
0

我有一个JSON响应与元信息删除分页元信息laravel 5

{"total":3594,"per_page":20,"current_page":18,"last_page":180,"next_page_url":"http:\/\/localhost:7777\/youtube\/public\/service\/category\/user_id\/education?page=19","prev_page_url":"http:\/\/localhost:7777\/app\/public\/test?page=17","from":341,"to":360 

我需要删除,仅显示选择的结果数据..

+0

我们需要更多的信息来帮助你... – PeterPan666

+0

我使用laravel 5.2返回分页数据,结果包含上面的分页元信息json它有total,per_page,current_page但我不需要显示元信息我只需要只包含选定数据的第二部分。 –

+0

@ AlaaMon3em我无法在您的json响应中找到结果数据。我错过了什么吗? – jaysingkar

回答

4

,如果你想在收集你能得到它搭配:

$paginated = Model::paginate(10); 
$collection = $paginated->getCollection(); 
0

假设您的型号名称是Product,那么你就可以得到的只是(不分页数据)这样的产品的数据:

// Add conditions to the query according to your needs 
$data = Product::paginate(10); 

// More info about toArray() method, see: vendor\laravel\framework\src\Illuminate\Pagination\LengthAwarePaginator.php file 
$result = $data->toArray(); 

// Now, what you need is the $result["data"] element 
$products = $result["data"]; 

$result该阵列是一个关联数组具有下列键:

current_page
data
first_page_urlfrom

last_page
​​
next_page_url
path
per_page
prev_page_url
to
total

您可以根据需要使用或取消设置$result阵列中的任何元素。