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

HomeController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 17
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getHomePageNews() 0 8 1
A index() 0 5 1
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