Laravel vuejs Pagination Ressource/Collection

I have a Pagination resource

public function toArray($request): array
{
return [
'current_page' => $this->currentPage(),
'last_page' => $this->lastPage(),
'links' => $this->links(),
'next_page_url' => $this->nextPageUrl(),
'count' => $this->count(),
'per_page' => $this->perPage(),
'prev_page_url' => $this->previousPageUrl(),
'total' => $this->total()
];
}

and a collection

 public function toArray($request):array
{
return [
'data' => $this->collection,
];
}

I have tried this one

 public function toArray($request) : Array
{
$pagination = new PaginationResource($this);

return [
'templates' => $this->collection,
$pagination::$wrap => $pagination,
];
}

But the result is like this

        'templates' => $this->$collection(),
'data' => $pagination,

I want to use the pagination Resource in the collection To have the Result like this

        'data' => $this->collection,
'current_page' => $this->currentPage(),
'last_page' => $this->lastPage(),
'links' => $this->links(),
'next_page_url' => $this->nextPageUrl(),
'count' => $this->count(),
'per_page' => $this->perPage(),
'prev_page_url' => $this->previousPageUrl(),
'total' => $this->total()

** Is there any solution to merge them (SortOf) **



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/37fMx0f
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

How to Create Treeview with Bootstrap and jQuery

Api routes not found when hosted laravel application on server

How to Add Images to Dropdown List using jQuery