IssuesController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 6
Bugs 1 Features 3
Metric Value
wmc 2
c 6
b 1
f 3
lcom 0
cbo 2
dl 0
loc 60
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B __construct() 0 26 1
A indexAction() 0 11 1
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\Issue;
15
use Gitamin\Models\Project;
16
use Illuminate\Foundation\Bus\DispatchesJobs;
17
use Illuminate\Routing\Controller;
18
use Illuminate\Support\Facades\Request;
19
use Illuminate\Support\Facades\View;
20
21
class IssuesController extends Controller
22
{
23
    use DispatchesJobs;
24
25
    /**
26
     * Stores the sub-sidebar tree list.
27
     *
28
     * @var array
29
     */
30
    protected $subMenu = [];
31
32
    /**
33
     * Creates a new issue controller instance.
34
     *
35
     * @return \Gitamin\Http\Controllers\IssueController
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...
36
     */
37
    public function __construct()
38
    {
39
        $this->subMenu = [
40
            'open' => [
41
                'title' => trans('dashboard.issues.open'),
42
                'url' => route('dashboard.issues.index', ['state' => 'opened']),
43
                'icon' => 'fa fa-eye',
44
                'active' => true,
45
            ],
46
            'closed' => [
47
                'title' => trans('dashboard.issues.closed'),
48
                'url' => route('dashboard.issues.index', ['state' => 'closed']),
49
                'icon' => 'fa fa-check-circle',
50
                'active' => false,
51
            ],
52
            'all' => [
53
                'title' => trans('dashboard.issues.all'),
54
                'url' => route('dashboard.issues.index', ['state' => 'all']),
55
                'icon' => 'fa fa-exclamation-circle',
56
                'active' => false,
57
            ],
58
        ];
59
60
        View::share('sub_menu', $this->subMenu);
61
        View::share('sub_title', trans('dashboard.issues.title'));
62
    }
63
64
    /**
65
     * Shows the issues view.
66
     *
67
     * @return \Illuminate\View\View
68
     */
69
    public function indexAction()
70
    {
71
        $state = Request::get('state');
72
        // Issue & Issue Project list.
73
        $usedIssueProjects = Issue::where('project_id', '>', 0)->where('state', '=', $state)->groupBy('project_id')->lists('project_id');
74
        $issueProjects = Project::whereIn('id', $usedIssueProjects)->get();
75
76
        return View::make('dashboard.issues.index')
77
            ->withIssueProjects($issueProjects)
78
            ->withPageTitle(trans('dashboard.issues.issues').' - '.trans('dashboard.dashboard'));
79
    }
80
}
81