|
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 ProjectsController 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
|
|
View Code Duplication |
public function __construct() |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
$this->subMenu = [ |
|
36
|
|
|
'yours' => [ |
|
37
|
|
|
'title' => trans('dashboard.projects.yours'), |
|
38
|
|
|
'url' => route('dashboard.projects.index'), |
|
39
|
|
|
'icon' => 'fa fa-edit', |
|
40
|
|
|
'active' => false, |
|
41
|
|
|
], |
|
42
|
|
|
'starred' => [ |
|
43
|
|
|
'title' => trans('dashboard.projects.starred'), |
|
44
|
|
|
'url' => route('dashboard.projects.starred'), |
|
45
|
|
|
'icon' => 'fa fa-umbrella', |
|
46
|
|
|
'active' => false, |
|
47
|
|
|
], |
|
48
|
|
|
'explore' => [ |
|
49
|
|
|
'title' => trans('dashboard.projects.explore'), |
|
50
|
|
|
'url' => route('explore.index'), |
|
51
|
|
|
'icon' => 'fa fa-eye', |
|
52
|
|
|
'active' => false, |
|
53
|
|
|
], |
|
54
|
|
|
]; |
|
55
|
|
|
|
|
56
|
|
|
View::share([ |
|
57
|
|
|
'sub_menu' => $this->subMenu, |
|
58
|
|
|
'sub_title' => trans_choice('dashboard.projects.projects', 2), |
|
59
|
|
|
]); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Shows the projects view. |
|
64
|
|
|
* |
|
65
|
|
|
* @return \Illuminate\View\View |
|
66
|
|
|
*/ |
|
67
|
|
View Code Duplication |
public function indexAction() |
|
|
|
|
|
|
68
|
|
|
{ |
|
69
|
|
|
$projects = Project::orderBy('created_at')->get(); |
|
70
|
|
|
$this->subMenu['yours']['active'] = true; |
|
71
|
|
|
|
|
72
|
|
|
return View::make('dashboard.projects.index') |
|
73
|
|
|
->withPageTitle(trans_choice('dashboard.projects.projects', 2).' - '.trans('dashboard.dashboard')) |
|
74
|
|
|
->withProjects($projects) |
|
75
|
|
|
->withSubMenu($this->subMenu); |
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
/** |
|
79
|
|
|
* Shows the starred projects view. |
|
80
|
|
|
* |
|
81
|
|
|
* @return \Illuminate\View\View |
|
82
|
|
|
*/ |
|
83
|
|
|
public function starredAction() |
|
84
|
|
|
{ |
|
85
|
|
|
$this->subMenu['starred']['active'] = true; |
|
86
|
|
|
$projects = Project::orderBy('created_at')->get(); |
|
87
|
|
|
|
|
88
|
|
|
return View::make('dashboard.projects.index') |
|
89
|
|
|
->withPageTitle(trans_choice('dashboard.projects.projects', 2).' - '.trans('dashboard.dashboard')) |
|
90
|
|
|
->withProjects($projects) |
|
91
|
|
|
->withSubMenu($this->subMenu); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
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.