namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\View\View;
use Joshbrw\PaginationSpecification\PaginationSpecification;
class UserController extends Controller {
public function index(
Request $request,
PaginationSpecification $paginationSpecification,
UserRepository $userRepository
): View {
// Reads the `per_page` and `page` values from the request
$paginationSpecification->fromRequest($request);
// Set how many items we want per page
$paginationSpecification->setPerPage(30);
// This can now be passed around to other methods, which can typehint it as a dependency
return $userRepository->get($paginationSpecification);
}
}