Issues (202)

src/Model/Base.php (1 issue)

1
<?php
2
3
namespace Siak\Tontine\Model;
4
5
use Illuminate\Database\Eloquent\Builder;
6
use Illuminate\Database\Eloquent\Model;
7
8
class Base extends Model
9
{
10
    /**
11
     * @param  Builder  $query
12
     * @param  int  $page
13
     * @param  int  $limit
14
     *
15
     * @return Builder
16
     */
17
    public function scopePage(Builder $query, int $page, int $limit): Builder
18
    {
19
        return $page < 1 || $limit < 1 ? $query :
0 ignored issues
show
Bug Best Practice introduced by
The expression return $page < 1 || $lim...kip($limit * $page - 1) could return the type Illuminate\Database\Query\Builder which is incompatible with the type-hinted return Illuminate\Database\Eloquent\Builder. Consider adding an additional type-check to rule them out.
Loading history...
20
            $query->take($limit)->skip($limit * ($page - 1));
21
    }
22
}
23