HomeController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A about() 0 11 1
A index() 0 11 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use App\Spot;
7
use App\Country;
8
9
class HomeController extends Controller
10
{
11
    /**
12
     * Show the application homepage
13
     *
14
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
15
     */
16
    public function index()
17
    {
18
        $featuredSpots = Spot::featured()->get();
19
20
        $spotsCount = Spot::count();
21
22
        $countriesCount = Country::whereHas('spots', function ($spot) {
23
            $spot->where('is_approved', true);
24
        })->count();
25
26
        return view('welcome', compact('featuredSpots', 'spotsCount', 'countriesCount'));
27
    }
28
29
    /**
30
     * Show the about us page.
31
     *
32
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
33
     */
34
    public function about()
35
    {
36
        $countriesWithSpots = Country::whereHas('spots', function($spot) {
37
            $spot->where('is_approved', true);
38
        })
39
        ->withCount(['spots' => function ($spots) {
40
            $spots->where('is_approved', true);
41
        }])
42
        ->orderBy('name_pt', 'ASC')->get();
43
44
        return view('about', compact('countriesWithSpots'));
45
    }
46
}
47