Skip to content

Commit

Permalink
Replace Illuminate\Database\Eloquent\Collection by Illuminate\Support…
Browse files Browse the repository at this point in the history
…\Collection to support collection of Laravel's Paginator.

So you can do in your Controller :

$articles = Article::paginate(5);

And in your 'app/views/articles/index.blade.php':

@div_for($articles->getCollection()) as($article)
    {{ $article->name }}
@end_div_for

More info about pagination with Laravel:
http://laravel.com/docs/4.2/pagination
  • Loading branch information
Tortue Torche committed Nov 3, 2014
1 parent 60aa832 commit 7e0914a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Efficiently/JqueryLaravel/BladeExtensions.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public function registerContentTags()
$replacement = <<<EOT
<?php
\${$recordName}Record = $record;
if (! is_a(\${$recordName}Record, "\Illuminate\Database\Eloquent\Collection")) {
\${$recordName}Record = new \Illuminate\Database\Eloquent\Collection([\${$recordName}Record]);
if (! is_a(\${$recordName}Record, "\Illuminate\Support\Collection")) {
\${$recordName}Record = new \Illuminate\Support\Collection([\${$recordName}Record]);
}
\${$recordIndex} = -1;// -1 because we increment index at the beginnning of the loop
\${$recordName}Record->each(function(\${$recordName}) use(\$__env, &\${$recordIndex}){
Expand Down

0 comments on commit 7e0914a

Please sign in to comment.