framework icon indicating copy to clipboard operation
framework copied to clipboard

[proposal] Paginator isEmpty

Open peter-mdf opened this issue 13 years ago • 1 comments

I created a list off all my clients. First off, I retrieved my clients from the database and sent it to a view:

Client::all();

When there are no clients, I show an message that we do not have any clients yet. So I am using the isEmpty() function:

<table class="table table-striped table-bordered margin-top">
                <thead>
                    <tr>
                        ......
                    </tr>
                </thead>
                <tbody>
                    @if ($clients->isEmpty())
                    <tr>
                        .......
                    </tr>
                    @endif
                    @foreach ($clients as $client)
                    <tr>
                       ......
                    </tr>
                    @endforeach
                </tbody>
            </table>

Now I wanted to include pagination, So I changed:

Client::all();

to

Client::paginate(10);

Unfortunately, I am now getting this error:

FatalErrorException: Error: Call to undefined method Illuminate\Pagination\Paginator::isEmpty()

I could use count() or getTotal() to check if I got any results. But wouldn't it make any sense if there was also an isEmpty() function?

peter-mdf avatar Jan 27 '13 00:01 peter-mdf

Sure. I'll look into adding it or someone can pull request it.

taylorotwell avatar Jan 27 '13 02:01 taylorotwell