|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* GitScrum v0.1. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Renato Marinho <[email protected]> |
|
6
|
|
|
* @license http://opensource.org/licenses/GPL-3.0 GPLv3 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace GitScrum\Http\Controllers; |
|
10
|
|
|
|
|
11
|
|
|
use GitScrum\Http\Requests\SprintRequest; |
|
12
|
|
|
use GitScrum\Models\ConfigStatus; |
|
13
|
|
|
use GitScrum\Models\ProductBacklog; |
|
14
|
|
|
use GitScrum\Models\Sprint; |
|
15
|
|
|
use Auth; |
|
16
|
|
|
use Illuminate\Http\Request; |
|
17
|
|
|
|
|
18
|
|
|
class SprintController extends Controller |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Display a listing of the resource. |
|
22
|
|
|
* |
|
23
|
|
|
* @return \Illuminate\Http\Response |
|
24
|
|
|
*/ |
|
25
|
|
|
public function index($mode = 'default', $slug_product_backlog = null) |
|
26
|
|
|
{ |
|
27
|
|
|
$sprints = Sprint::orderby('date_start', 'DESC') |
|
28
|
|
|
->orderby('date_finish', 'ASC'); |
|
29
|
|
|
|
|
30
|
|
|
if (!is_null($slug_product_backlog)) { |
|
31
|
|
|
$sprints = $sprints->join('product_backlogs', 'product_backlogs.id', 'sprints.product_backlog_id') |
|
32
|
|
|
->where('product_backlogs.slug', $slug_product_backlog); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
$sprints = $sprints->with('issues') |
|
36
|
|
|
->with('favorite') |
|
37
|
|
|
->with('status') |
|
38
|
|
|
->select('sprints.*') |
|
39
|
|
|
->paginate(env('APP_PAGINATE')); |
|
40
|
|
|
|
|
41
|
|
|
return view('sprints.index-'.$mode) |
|
|
|
|
|
|
42
|
|
|
->with('sprints', $sprints); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Show the form for creating a new resource. |
|
47
|
|
|
* |
|
48
|
|
|
* @return \Illuminate\Http\Response |
|
49
|
|
|
*/ |
|
50
|
|
|
public function create($slug_product_backlog = null) |
|
51
|
|
|
{ |
|
52
|
|
|
$productBacklog_id = null; |
|
53
|
|
|
|
|
54
|
|
|
if (!is_null($slug_product_backlog)) { |
|
55
|
|
|
$productBacklog_id = ProductBacklog::slug($slug_product_backlog)->first()->id; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
return view('sprints.create') |
|
|
|
|
|
|
59
|
|
|
->with('productBacklogs', Auth::user()->productBacklogs()) |
|
60
|
|
|
->with('productBacklog_id', $productBacklog_id) |
|
61
|
|
|
->with('action', 'Create'); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Store a newly created resource in storage. |
|
66
|
|
|
* |
|
67
|
|
|
* @param GitScrum\Http\Requests\SprintRequest $request |
|
68
|
|
|
* |
|
69
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
70
|
|
|
*/ |
|
71
|
|
|
public function store(SprintRequest $request) |
|
72
|
|
|
{ |
|
73
|
|
|
$sprint = Sprint::create($request->all()); |
|
74
|
|
|
|
|
75
|
|
|
return redirect()->route('sprints.show', ['slug' => $sprint->slug]) |
|
|
|
|
|
|
76
|
|
|
->with('success', trans('Congratulations! The Sprint has been created with successfully')); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* Display the specified resource. |
|
81
|
|
|
* |
|
82
|
|
|
* @param str $slug |
|
83
|
|
|
* |
|
84
|
|
|
* @return \Illuminate\Http\Response |
|
85
|
|
|
*/ |
|
86
|
|
|
public function show($slug) |
|
87
|
|
|
{ |
|
88
|
|
|
$sprint = Sprint::slug($slug) |
|
89
|
|
|
->with('issues.user') |
|
90
|
|
|
->with('issues.users') |
|
91
|
|
|
->with('issues.commits') |
|
92
|
|
|
->with('branches.user') |
|
93
|
|
|
->with('branches.commits') |
|
94
|
|
|
->with('branches.commits.files') |
|
95
|
|
|
->with('issues.statuses') |
|
96
|
|
|
->with('issues.statuses.configStatus') |
|
97
|
|
|
->with('issues.statuses.configStatus.users') |
|
98
|
|
|
->with('issues.statuses.user') |
|
99
|
|
|
->with('issues.statuses.statusesable') |
|
100
|
|
|
->with('notes') |
|
101
|
|
|
->first(); |
|
102
|
|
|
|
|
103
|
|
|
if (!count($sprint)) { |
|
104
|
|
|
return redirect()->route('sprints.index'); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
$configStatus = ConfigStatus::type('sprint')->get(); |
|
108
|
|
|
|
|
109
|
|
|
return view('sprints.show') |
|
|
|
|
|
|
110
|
|
|
->with('sprint', $sprint) |
|
111
|
|
|
->with('configStatus', $configStatus); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* Show the form for editing the specified resource. |
|
116
|
|
|
* |
|
117
|
|
|
* @param $slug |
|
118
|
|
|
* |
|
119
|
|
|
* @return \Illuminate\Http\Response |
|
120
|
|
|
* |
|
121
|
|
|
* @internal param int $id |
|
122
|
|
|
*/ |
|
123
|
|
|
public function edit($slug) |
|
124
|
|
|
{ |
|
125
|
|
|
$sprint = Sprint::slug($slug)->first(); |
|
126
|
|
|
|
|
127
|
|
|
return view('sprints.edit') |
|
|
|
|
|
|
128
|
|
|
->with('action', 'Edit') |
|
129
|
|
|
->with('sprint', $sprint); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Update the specified resource in storage. |
|
134
|
|
|
* |
|
135
|
|
|
* @param SprintRequest|Request $request |
|
136
|
|
|
* @param $slug |
|
137
|
|
|
* |
|
138
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
139
|
|
|
* |
|
140
|
|
|
* @internal param int $id |
|
141
|
|
|
*/ |
|
142
|
|
|
public function update(SprintRequest $request, $slug) |
|
143
|
|
|
{ |
|
144
|
|
|
$sprint = Sprint::slug($slug)->first(); |
|
145
|
|
|
$sprint->update($request->all()); |
|
146
|
|
|
|
|
147
|
|
|
return back() |
|
148
|
|
|
->with('success', trans('Congratulations! The Sprint has been edited with successfully')); |
|
149
|
|
|
} |
|
150
|
|
|
|
|
151
|
|
|
/** |
|
152
|
|
|
* Remove the specified resource from storage. |
|
153
|
|
|
* |
|
154
|
|
|
* @param Request $request |
|
155
|
|
|
* |
|
156
|
|
|
* @return \Illuminate\Http\Response |
|
|
|
|
|
|
157
|
|
|
* |
|
158
|
|
|
* @internal param int $id |
|
159
|
|
|
*/ |
|
160
|
|
|
public function destroy(Request $request) |
|
161
|
|
|
{ |
|
162
|
|
|
$sprint = Sprint::slug($request->input('slug'))->first(); |
|
163
|
|
|
|
|
164
|
|
|
if (!count($sprint)) { |
|
165
|
|
|
return redirect()->route('sprints.index'); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
$sprint->delete(); |
|
169
|
|
|
|
|
170
|
|
|
return redirect()->route('sprints.index') |
|
171
|
|
|
->with('success', trans('Congratulations! The Sprint has been deleted successfully')); |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
public function statusUpdate($slug, $status) |
|
175
|
|
|
{ |
|
176
|
|
|
$sprint = Sprint::slug($slug) |
|
177
|
|
|
->firstOrFail(); |
|
178
|
|
|
$sprint->config_status_id = $status; |
|
179
|
|
|
$sprint->save(); |
|
180
|
|
|
|
|
181
|
|
|
return back()->with('success', trans('Updated successfully')); |
|
182
|
|
|
} |
|
183
|
|
|
} |
|
184
|
|
|
|
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: