GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PagesController::create()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace Chadanuk\MiniCms\Http\Controllers;
4
5
use Chadanuk\MiniCms\Page;
6
use Illuminate\Http\Request;
7
use Illuminate\Support\Facades\View;
8
9
class PagesController
10
{
11
    public function show(Page $page, Request $request)
12
    {
13
        if ($request->is('/')) {
14
            $page = Page::where('slug', 'home')->first();
15
        }
16
        $viewPath = $page->getViewPath();
17
18
        return View::make($viewPath, ['page' => $page]);
19
    }
20
21
    public function index()
22
    {
23
        $pages = Page::all();
24
        if (View::exists('mini-cms.admin.pages.list')) {
25
            return View('mini-cms.admin.pages.list', ['pages' => $pages]);
26
        }
27
28
        return View::make('mini-cms::admin.pages.list', ['pages' => $pages]);
29
    }
30
31
    public function edit(Request $request, $id)
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
    {
33
        $page = Page::find($id);
34
35
        $page->fetchBlocks();
36
37
        if (View::exists('mini-cms.admin.pages.edit')) {
38
            return View('mini-cms.admin.pages.edit', ['page' => $page]);
39
        }
40
41
        return View::make('mini-cms::admin.pages.edit', ['page' => $page]);
42
    }
43
44
    public function update(Request $request, $id)
45
    {
46
        $page = Page::find($id);
47
48
        $page->update([
49
            'name' => $request->get('name', $page->name),
50
            'slug' => $request->get('slug', $page->slug),
51
        ]);
52
53
        $page->updateBlocks($request->get('blocks'));
54
55
        return redirect()->route('mini-cms.pages.edit', ['id' => $id])->with('success', true);
56
    }
57
58
    public function create()
59
    {
60
        if (View::exists('mini-cms.admin.pages.create')) {
61
            return View('mini-cms.admin.pages.create');
62
        }
63
64
        return View::make('mini-cms::admin.pages.create');
65
    }
66
67
    public function store(Request $request)
68
    {
69
        $page = \MiniCms::createPage([
70
            'name' => $request->get('name'),
71
72
        ]);
73
74
        return redirect()->route('mini-cms.pages.edit', ['id' => $page->id])->with('success', true);
75
    }
76
}
77