for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace mav3rick177\RapidPagination\Http\Resources\Json;
use Illuminate\Http\Resources\Json\PaginatedResourceResponse;
use Illuminate\Pagination\AbstractPaginator;
use mav3rick177\RapidPagination\PaginationResult;
/**
* Trait RespondsWithPaginationResult
*
* @mixin \Illuminate\Http\Resources\Json\ResourceCollection
*/
trait RespondsWithPaginationResult
{
* Create an HTTP response that represents the object.
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\JsonResponse
public function toResponse($request)
if ($this->resource instanceof AbstractPaginator) {
resource
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
class MyClass { } $x = new MyClass(); $x->foo = true;
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:
class MyClass { public $foo; } $x = new MyClass(); $x->foo = true;
return (new PaginatedResourceResponse($this))->toResponse($request);
}
if ($this->resource instanceof PaginationResult) {
return (new PaginationResultResourceResponse($this))->toResponse($request);
return parent::toResponse($request);
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: