Answers for "collection relation pagination laravel"

PHP
3

paginate relationship laravel7

$category = Category::first();
$apps = $category->apps()->paginate(10);
return view('example', compact('category', 'apps'));
Posted by: Guest on July-11-2020
1

laravel's collection pagination

// this goes to -> appProvidersAppServiceProvider -> boot function

        use IlluminatePaginationLengthAwarePaginator;
        use IlluminateSupportCollection;

		Collection::macro('paginate', function($perPage, $total = null, $page = null, $pageName = 'page') {
            $page = $page ?: LengthAwarePaginator::resolveCurrentPage($pageName);
            return new LengthAwarePaginator(
                $this->forPage($page, $perPage),
                $total ?: $this->count(),
                $perPage,
                $page,
                [
                    'path' => LengthAwarePaginator::resolveCurrentPath(),
                    'pageName' => $pageName,
                ]
            );
        });

	// this goes to controller. collection->paginate(1);
	$event->paginate(1);
Posted by: Guest on August-14-2021

Code answers related to "collection relation pagination laravel"

Browse Popular Code Answers by Language