File tree Expand file tree Collapse file tree 1 file changed +27
-21
lines changed Expand file tree Collapse file tree 1 file changed +27
-21
lines changed Original file line number Diff line number Diff line change 10
10
trait Paginateable
11
11
{
12
12
13
- /** @var string */
14
- protected $ paginateablePageKey = 'page ' ;
13
+ /** @var string */
14
+ protected $ paginateablePageKey = 'page ' ;
15
15
16
- /** @var string */
17
- protected $ paginateablePerPageKey = 'per_page ' ;
16
+ /** @var string */
17
+ protected $ paginateablePerPageKey = 'per_page ' ;
18
18
19
- /**
20
- * @param \Illuminate\Database\Eloquent\Builder $query
21
- * @return \Illuminate\Database\Eloquent\Model[]|\Illuminate\Contracts\Pagination\LengthAwarePaginator|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection
22
- */
23
- public function scopePaginateable (Builder $ query )
24
- {
25
- if (request ()->hasFilled ([$ this ->paginateablePageKey , $ this ->paginateablePerPageKey ]))
26
- {
27
- return $ query ->paginate (
28
- request ()->input ('per_page ' , $ this ->getPerPage ()),
29
- ['* ' ],
30
- $ this ->paginateablePageKey
31
- );
32
- }
19
+ /**
20
+ * @param \Illuminate\Database\Eloquent\Builder $query
21
+ * @param bool $simple
22
+ * @return \Illuminate\Database\Eloquent\Model[]|\Illuminate\Contracts\Pagination\Paginator|\Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection
23
+ */
24
+ public function scopePaginateable (Builder $ query , $ simple = false )
25
+ {
26
+ if (request ()->hasFilled ([$ this ->paginateablePageKey , $ this ->paginateablePerPageKey ]))
27
+ {
28
+ return $ simple ?
29
+ $ query ->simplePaginate (
30
+ request ()->input ('per_page ' , $ this ->getPerPage ()),
31
+ ['* ' ],
32
+ $ this ->paginateablePageKey
33
+ ) : $ query ->paginate (
34
+ request ()->input ('per_page ' , $ this ->getPerPage ()),
35
+ ['* ' ],
36
+ $ this ->paginateablePageKey
37
+ );
38
+ }
33
39
34
- return $ query ->get ();
35
- }
36
- }
40
+ return $ query ->get ();
41
+ }
42
+ }
You can’t perform that action at this time.
0 commit comments