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 AltThree\Validator\ValidationException; |
15
|
|
|
use Gitamin\Commands\Project\AddProjectCommand; |
16
|
|
|
use Gitamin\Commands\Project\RemoveProjectCommand; |
17
|
|
|
use Gitamin\Commands\Project\UpdateProjectCommand; |
18
|
|
|
use Gitamin\Models\Owner; |
19
|
|
|
use Gitamin\Models\Project; |
20
|
|
|
use Gitamin\Models\Tag; |
21
|
|
|
use GrahamCampbell\Binput\Facades\Binput; |
22
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs; |
23
|
|
|
use Illuminate\Routing\Controller; |
24
|
|
|
use Illuminate\Support\Facades\Redirect; |
25
|
|
|
use Illuminate\Support\Facades\View; |
26
|
|
|
|
27
|
|
|
class ProjectController extends Controller |
28
|
|
|
{ |
29
|
|
|
use DispatchesJobs; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Array of sub-menu items. |
33
|
|
|
* |
34
|
|
|
* @var array |
35
|
|
|
*/ |
36
|
|
|
protected $subMenu = []; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Creates a new project controller instance. |
40
|
|
|
* |
41
|
|
|
* @return void |
|
|
|
|
42
|
|
|
*/ |
43
|
|
|
public function __construct() |
44
|
|
|
{ |
45
|
|
|
$this->subMenu = [ |
46
|
|
|
'yours' => [ |
47
|
|
|
'title' => trans('dashboard.projects.yours'), |
48
|
|
|
'url' => route('dashboard.projects.index'), |
49
|
|
|
'icon' => 'fa fa-edit', |
50
|
|
|
'active' => false, |
51
|
|
|
], |
52
|
|
|
'starred' => [ |
53
|
|
|
'title' => trans('dashboard.projects.starred'), |
54
|
|
|
'url' => route('dashboard.projects.starred'), |
55
|
|
|
'icon' => 'fa fa-umbrella', |
56
|
|
|
'active' => false, |
57
|
|
|
], |
58
|
|
|
'explore' => [ |
59
|
|
|
'title' => trans('dashboard.projects.explore'), |
60
|
|
|
'url' => route('explore.index'), |
61
|
|
|
'icon' => 'fa fa-eye', |
62
|
|
|
'active' => false, |
63
|
|
|
], |
64
|
|
|
]; |
65
|
|
|
|
66
|
|
|
View::share([ |
67
|
|
|
'sub_menu' => $this->subMenu, |
68
|
|
|
'sub_title' => trans_choice('dashboard.projects.projects', 2), |
69
|
|
|
]); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Shows the projects view. |
74
|
|
|
* |
75
|
|
|
* @return \Illuminate\View\View |
76
|
|
|
*/ |
77
|
|
View Code Duplication |
public function indexAction() |
|
|
|
|
78
|
|
|
{ |
79
|
|
|
$projects = Project::orderBy('created_at')->get(); |
80
|
|
|
$this->subMenu['yours']['active'] = true; |
81
|
|
|
|
82
|
|
|
return View::make('dashboard.projects.index') |
83
|
|
|
->withPageTitle(trans_choice('dashboard.projects.projects', 2).' - '.trans('dashboard.dashboard')) |
84
|
|
|
->withProjects($projects) |
85
|
|
|
->withSubMenu($this->subMenu); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Shows the starred projects view. |
90
|
|
|
* |
91
|
|
|
* @return \Illuminate\View\View |
92
|
|
|
*/ |
93
|
|
|
public function starredAction() |
94
|
|
|
{ |
95
|
|
|
$this->subMenu['starred']['active'] = true; |
96
|
|
|
$projects = Project::orderBy('created_at')->get(); |
97
|
|
|
|
98
|
|
|
$this->subMenu['starred']['active'] = true; |
99
|
|
|
|
100
|
|
|
return View::make('dashboard.projects.index') |
101
|
|
|
->withPageTitle(trans_choice('dashboard.projects.projects', 2).' - '.trans('dashboard.dashboard')) |
102
|
|
|
->withProjects($projects) |
103
|
|
|
->withSubMenu($this->subMenu); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
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.