Completed
Pull Request — master (#70)
by Phecho
05:23 queued 10s
created

ProjectController::starredAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4286
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of Gitamin.
5
 * 
6
 * Copyright (C) 2015-2016 The Gitamin Team
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Gitamin\Http\Controllers\Dashboard;
13
14
use Gitamin\Models\Project;
15
use Illuminate\Foundation\Bus\DispatchesJobs;
16
use Illuminate\Routing\Controller;
17
use Illuminate\Support\Facades\View;
18
19
class ProjectController extends Controller
20
{
21
    use DispatchesJobs;
22
23
    /**
24
     * Array of sub-menu items.
25
     *
26
     * @var array
27
     */
28
    protected $subMenu = [];
29
30
    /**
31
     * Creates a new project controller instance.
32
     *
33
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
34
     */
35
    public function __construct()
36
    {
37
        $this->subMenu = [
38
            'yours' => [
39
                'title'  => trans('dashboard.projects.yours'),
40
                'url'    => route('dashboard.projects.index'),
41
                'icon'   => 'fa fa-edit',
42
                'active' => false,
43
            ],
44
            'starred' => [
45
                'title'  => trans('dashboard.projects.starred'),
46
                'url'    => route('dashboard.projects.starred'),
47
                'icon'   => 'fa fa-umbrella',
48
                'active' => false,
49
            ],
50
            'explore' => [
51
                'title'  => trans('dashboard.projects.explore'),
52
                'url'    => route('explore.index'),
53
                'icon'   => 'fa fa-eye',
54
                'active' => false,
55
            ],
56
        ];
57
58
        View::share([
59
            'sub_menu'  => $this->subMenu,
60
            'sub_title' => trans_choice('dashboard.projects.projects', 2),
61
        ]);
62
    }
63
64
    /**
65
     * Shows the projects view.
66
     *
67
     * @return \Illuminate\View\View
68
     */
69 View Code Duplication
    public function indexAction()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70
    {
71
        $projects = Project::orderBy('created_at')->get();
72
        $this->subMenu['yours']['active'] = true;
73
74
        return View::make('dashboard.projects.index')
75
            ->withPageTitle(trans_choice('dashboard.projects.projects', 2).' - '.trans('dashboard.dashboard'))
76
            ->withProjects($projects)
77
            ->withSubMenu($this->subMenu);
78
    }
79
80
    /**
81
     * Shows the starred projects view.
82
     *
83
     * @return \Illuminate\View\View
84
     */
85
    public function starredAction()
86
    {
87
        $this->subMenu['starred']['active'] = true;
88
        $projects = Project::orderBy('created_at')->get();
89
90
        $this->subMenu['starred']['active'] = true;
91
92
        return View::make('dashboard.projects.index')
93
            ->withPageTitle(trans_choice('dashboard.projects.projects', 2).' - '.trans('dashboard.dashboard'))
94
            ->withProjects($projects)
95
            ->withSubMenu($this->subMenu);
96
    }
97
}
98