|
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 |
|
|
|
|
|
|
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() |
|
|
|
|
|
|
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
|
|
|
|
Adding a
@returnannotation 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.