Passed
Push — terms-contact ( f02a40 )
by Fèvre
07:19
created

PageController::terms()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Xetaravel\Http\Controllers;
3
4
use Xetaravel\Models\Article;
5
use Xetaravel\Models\Comment;
6
use Illuminate\Support\Facades\Auth;
7
8
class PageController extends Controller
9
{
10
    /**
11
     * Show the home page.
12
     *
13
     * @return \Illuminate\Http\Response
14
     */
15
    public function index()
16
    {
17
        $articles = Article::with('category', 'user')
18
            ->latest()
19
            ->limit(6)
20
            ->get();
21
22
        $comments = Comment::with('user')
23
            ->whereHas('article', function ($query) {
24
                $query->where('is_display', true);
25
            })
26
            ->latest()
27
            ->limit(4)
28
            ->get();
29
30
        return view('page.index', ['articles' => $articles, 'comments' => $comments]);
31
    }
32
33
    /**
34
     * Display the terms page.
35
     *
36
     * @return \Illuminate\Http\Response
37
     */
38
    public function terms()
39
    {
40
41
        $this->breadcrumbs->addCrumb('Terms', route('page.terms'));
42
43
        return view('page.terms', ['breadcrumbs' => $this->breadcrumbs]);
44
    }
45
46
    /**
47
     * Display the banished page.
48
     *
49
     * @return \Illuminate\Http\Response
50
     */
51
    public function banished()
52
    {
53
        if (!Auth::user()->hasRole('banished')) {
54
            return redirect()
55
                ->route('page.index');
56
        }
57
58
        return view('page.banished');
59
    }
60
}
61