|
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 Illuminate\Http\Request; |
|
12
|
|
|
use GitScrum\Http\Requests\UserStoryRequest; |
|
13
|
|
|
use GitScrum\Models\UserStory; |
|
14
|
|
|
use GitScrum\Models\ConfigPriority; |
|
15
|
|
|
use GitScrum\Models\ProductBacklog; |
|
16
|
|
|
use GitScrum\Classes\Helper; |
|
17
|
|
|
use Auth; |
|
18
|
|
|
|
|
19
|
|
|
class UserStoryController extends Controller |
|
20
|
|
|
{ |
|
21
|
|
|
public function index(Request $request) |
|
|
|
|
|
|
22
|
|
|
{ |
|
23
|
|
|
$userStories = Helper::lengthAwarePaginator(Auth::user()->userStories(), $request->page); |
|
24
|
|
|
return view('user_stories.index') |
|
|
|
|
|
|
25
|
|
|
->with('userStories', $userStories); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function create($slug_product_backlog = null) |
|
|
|
|
|
|
29
|
|
|
{ |
|
30
|
|
|
$productBacklog_id = null; |
|
31
|
|
|
|
|
32
|
|
|
if (!is_null($slug_product_backlog)) { |
|
33
|
|
|
$productBacklog_id = ProductBacklog::slug($slug_product_backlog)->first()->id; |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
$priorities = ConfigPriority::where('enabled', 1) |
|
37
|
|
|
->orderby('position', 'ASC')->get(); |
|
38
|
|
|
|
|
39
|
|
|
return view('user_stories.create') |
|
|
|
|
|
|
40
|
|
|
->with('productBacklogs', Auth::user()->productBacklogs()) |
|
41
|
|
|
->with('productBacklog_id', $productBacklog_id) |
|
42
|
|
|
->with('priorities', $priorities) |
|
43
|
|
|
->with('action', 'Create'); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
public function store(UserStoryRequest $request) |
|
47
|
|
|
{ |
|
48
|
|
|
$userStory = UserStory::create($request->all()); |
|
49
|
|
|
|
|
50
|
|
|
return redirect()->route('user_stories.show', ['slug' => $userStory->slug]) |
|
|
|
|
|
|
51
|
|
|
->with('success', trans('Congratulations! The User Story has been created with successfully')); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
public function show($slug) |
|
|
|
|
|
|
55
|
|
|
{ |
|
56
|
|
|
$userStory = UserStory::slug($slug) |
|
57
|
|
|
->with('labels') |
|
58
|
|
|
->first(); |
|
59
|
|
|
|
|
60
|
|
|
return view('user_stories.show') |
|
|
|
|
|
|
61
|
|
|
->with('userStory', $userStory); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
public function edit($slug) |
|
|
|
|
|
|
65
|
|
|
{ |
|
66
|
|
|
$userStory = UserStory::slug($slug)->first(); |
|
67
|
|
|
|
|
68
|
|
|
$priorities = ConfigPriority::where('enabled', 1) |
|
69
|
|
|
->orderby('position', 'ASC')->get(); |
|
70
|
|
|
|
|
71
|
|
|
return view('user_stories.edit') |
|
|
|
|
|
|
72
|
|
|
->with('productBacklogs', Auth::user()->productBacklogs()) |
|
73
|
|
|
->with('userStory', $userStory) |
|
74
|
|
|
->with('productBacklog_id', $userStory->product_backlog_id) |
|
75
|
|
|
->with('priorities', $priorities) |
|
76
|
|
|
->with('action', 'Edit'); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
public function update(UserStoryRequest $request, $slug) |
|
80
|
|
|
{ |
|
81
|
|
|
$userStory = UserStory::slug($slug)->first(); |
|
82
|
|
|
$userStory->update($request->all()); |
|
83
|
|
|
|
|
84
|
|
|
return back() |
|
85
|
|
|
->with('success', trans('Congratulations! The User Story has been edited with successfully')); |
|
86
|
|
|
} |
|
87
|
|
|
|
|
88
|
|
|
public function destroy(Request $request) |
|
89
|
|
|
{ |
|
90
|
|
|
$userStory = UserStory::slug($request->slug)->firstOrFail(); |
|
91
|
|
|
$userStory->delete(); |
|
92
|
|
|
|
|
93
|
|
|
return redirect()->route('product_backlogs.index'); |
|
94
|
|
|
} |
|
95
|
|
|
} |
|
96
|
|
|
|
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.