PHP code example of codelabmw / laravel-infinite-scroll

1. Go to this page and download the library: Download codelabmw/laravel-infinite-scroll library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codelabmw / laravel-infinite-scroll example snippets




declare(strict_types=1);

namespace App\Http\Controllers;

use App\Models\Article;
use Codelabmw\InfiniteScroll\Facades\InfiniteScroll;
use Inertia\Inertia;

final class ArticleController extends Controller
{
    public function index()
    {
        $articles = Article::query();
        // You can use a Builder, CursorPaginator, or Paginator
        return Inertia::render('articles/index', InfiniteScroll::make('articles', $articles));
    }
}

InfiniteScroll::make('articles', Article::query());

namespace Codelabmw\InfiniteScroll\Stacks;

use Codelabmw\InfiniteScroll\Contracts\Stack;

final class MyStack implements Stack
{
    /**
     * The display name of the stack.
     */
    public function getLabel(): string
    {
        return 'MyStack';
    }

    /**
     * The default installation path of components for this stack.
     */
    public function getDefaultInstallationPath(): string
    {
        return 'resources/js/components';
    }

    /**
     * The paths of the stubs to copy.
     *
     * @return Collection<int, string>
     */
    public function getStubs(): Collection
    {
        return collect([
            FileSystem::stubs('my-stack/infinite-scroll.ext'),
        ]);
    }

    /**
     * Whether this stack is the current one.
     */
    public function isCurrent(): bool
    {
        return $this->isTheCurrentStackInUseByApplication();
    }
}

//...

class SupportedStacks
{
    /**
     * @return array<int, class-string<Stack>>
     */
    public function get(): array
    {
        return [
            //...
            MyStack::class,
        ];
    }
}
bash
php artisan install:infinite-scroll