1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the Tinyissue package. |
5
|
|
|
* |
6
|
|
|
* (c) Mohamed Alsharaf <[email protected]> |
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 Tinyissue\Http\Controllers; |
13
|
|
|
|
14
|
|
|
use Tinyissue\Form\UserSetting as Form; |
15
|
|
|
use Tinyissue\Http\Requests\FormRequest; |
16
|
|
|
use Tinyissue\Model\Project; |
17
|
|
|
use Tinyissue\Model\User; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* UserController is the controller class for managing request related to logged in user account. |
21
|
|
|
* |
22
|
|
|
* @author Mohamed Alsharaf <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
class UserController extends Controller |
25
|
|
|
{ |
26
|
|
|
/** |
27
|
|
|
* Edit the user's settings. |
28
|
|
|
* |
29
|
|
|
* @param Form $form |
30
|
|
|
* |
31
|
|
|
* @return \Illuminate\View\View |
32
|
|
|
*/ |
33
|
3 |
|
public function getSettings(Form $form) |
34
|
|
|
{ |
35
|
3 |
|
return view('user.settings', [ |
|
|
|
|
36
|
3 |
|
'form' => $form, |
37
|
3 |
|
'projects' => $this->auth->user()->projects()->get(), |
|
|
|
|
38
|
|
|
]); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* To update user settings. |
43
|
|
|
* |
44
|
|
|
* @param FormRequest\UserSetting $request |
45
|
|
|
* |
46
|
|
|
* @return \Illuminate\Http\RedirectResponse |
47
|
|
|
*/ |
48
|
2 |
|
public function postSettings(FormRequest\UserSetting $request) |
49
|
|
|
{ |
50
|
2 |
|
$this->auth->user()->updateSetting($request->all()); |
|
|
|
|
51
|
|
|
|
52
|
2 |
|
return redirect('user/settings')->with('notice', trans('tinyissue.settings_updated')); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Shows the user's assigned issues. |
57
|
|
|
* |
58
|
|
|
* @param string $display |
59
|
|
|
* @param Project $project |
60
|
|
|
* |
61
|
|
|
* @return \Illuminate\View\View |
62
|
|
|
*/ |
63
|
1 |
|
public function getIssues($display = 'list', Project $project = null) |
64
|
|
|
{ |
65
|
1 |
|
$view = $display === 'kanban' ? 'kanban' : 'list'; |
66
|
1 |
|
$data = []; |
67
|
|
|
|
68
|
1 |
|
if ($display === 'kanban') { |
69
|
|
|
$data['columns'] = []; |
70
|
|
|
$data['issues'] = []; |
71
|
|
|
if ($project->id) { |
72
|
|
|
$data['columns'] = $project->getKanbanTags(); |
73
|
|
|
$ids = $data['columns']->lists('id')->all(); |
74
|
|
|
$data['issues'] = $project->issuesGroupByTags($ids); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
$data['project'] = $project; |
78
|
|
|
$data['projects'] = $this->auth->user()->projects()->get(); |
|
|
|
|
79
|
|
|
} else { |
80
|
1 |
|
$data['projects'] = $this->auth->user()->projectsWidthIssues(Project::STATUS_OPEN)->get(); |
|
|
|
|
81
|
|
|
} |
82
|
|
|
|
83
|
1 |
|
return view('user.issues-' . $view, $data); |
|
|
|
|
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|