HomeController::index()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Repositories\ProductsRepository;
6
7
class HomeController extends Controller
8
{
9
    /**
10
     * @var ProductsRepository
11
     */
12
    protected $products;
13
14
    /**
15
     * HomeController constructor.
16
     * @param ProductsRepository $productsRepository
17
     */
18
    public function __construct(ProductsRepository $productsRepository)
19
    {
20
        $this->products = $productsRepository;
21
    }
22
23
    /**
24
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
25
     */
26
    public function index()
27
    {
28
        if($filters = request()->all())
29
        {
30
            $products = $this->products->search($filters);
31
            
32
            return view('home.search_result', compact('products'));
33
        }
34
35
        return view('home.index');
36
    }
37
38
}