Completed
Push — dev ( 6a43cb...d311da )
by Zach
03:42
created

SettingsController::showPages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 13
rs 9.4285
1
<?php
2
3
namespace Larafolio\Http\Controllers;
4
5
use View;
6
use Larafolio\Models\Page;
7
use Larafolio\Models\Project;
8
9
class SettingsController extends Controller
10
{
11
    /**
12
     * Show the requested settings page if it exists.
13
     *
14
     * @param string $page Settings page name.
15
     *
16
     * @return \Illuminate\Http\Response
17
     */
18
    public function show($page)
19
    {
20
        if (!View::exists("larafolio::settings.{$page}")) {
21
            abort(404);
22
        }
23
24
        if (method_exists($this, $method = 'show'.ucfirst($page))) {
25
            return $this->{$method}();
26
        }
27
28
        return view("larafolio::settings.{$page}");
29
    }
30
31
    /**
32
     * Show the projects settings page.
33
     *
34
     * @return \Illuminate\Http\Response
35
     */
36
    private function showProjects()
37
    {
38
        $deletedProjects = Project::onlyTrashed()
39
            ->orderBy('deleted_at', 'DESC')
40
            ->get()
41
            ->map(function (Project $project) {
42
                return $project->generateProps();
43
            });
44
45
        return view('larafolio::settings.projects', [
46
            'deletedProjects' => $deletedProjects,
47
        ]);
48
    }
49
50
    /**
51
     * Show the pages settings page.
52
     *
53
     * @return \Illuminate\Http\Response
54
     */
55
    private function showPages()
56
    {
57
        $deletedPages = Page::onlyTrashed()
1 ignored issue
show
Bug introduced by
The method onlyTrashed() does not exist on Larafolio\Models\Page. Did you maybe mean trashed()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
58
            ->orderBy('deleted_at', 'DESC')
59
            ->get()
60
            ->map(function (Page $page) {
61
                return $page->generateProps();
62
            });
63
64
        return view('larafolio::settings.pages', [
65
            'deletedPages' => $deletedPages,
66
        ]);
67
    }
68
}
69