Test Setup Failed
Push — master ( ef125c...60f940 )
by he
08:55
created

HomeController::index()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
namespace App\Http\Controllers\Web;
4
5
use App\Http\Controllers\Controller;
6
use App\Repositories\Criteria\Where;
7
use App\Repositories\PostRepository;
8
use Czim\Repository\Criteria\Common\OrderBy;
9
10
class HomeController extends Controller
11
{
12
    public function index()
13
    {
14
        $news = $this->getHomePageNews();
15
16
        return view('web.home')->with('news', $news);
17
    }
18
19
    private function getHomePageNews()
20
    {
21
        /** @var PostRepository $repo */
22
        $repo = app(PostRepository::class);
23
        $repo->pushCriteria(new Where('status', 1));
24
        $repo->pushCriteria(new OrderBy('created_at', 'desc'));
25
26
        return $repo->paginate(request('per_page', 3));
0 ignored issues
show
Bug introduced by
request('per_page', 3) of type Illuminate\Http\Request|array|string is incompatible with the type integer expected by parameter $perPage of Czim\Repository\BaseRepository::paginate(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

26
        return $repo->paginate(/** @scrutinizer ignore-type */ request('per_page', 3));
Loading history...
27
    }
28
}
29