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 Illuminate\Database\Eloquent\Collection; |
15
|
|
|
use Tinyissue\Form\UserSetting as Form; |
16
|
|
|
use Tinyissue\Http\Requests\FormRequest; |
17
|
|
|
use Tinyissue\Model\Project; |
18
|
|
|
use Tinyissue\Model\Tag; |
19
|
|
|
use Tinyissue\Model\User; |
20
|
|
|
use Illuminate\Database\Eloquent\Relations\Relation; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* UserController is the controller class for managing request related to logged in user account |
24
|
|
|
* |
25
|
|
|
* @author Mohamed Alsharaf <[email protected]> |
26
|
|
|
*/ |
27
|
|
|
class UserController extends Controller |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* Edit the user's settings |
31
|
|
|
* |
32
|
|
|
* @param Form $form |
33
|
|
|
* |
34
|
|
|
* @return \Illuminate\View\View |
35
|
|
|
*/ |
36
|
3 |
|
public function getSettings(Form $form) |
37
|
|
|
{ |
38
|
3 |
|
return view('user.settings', [ |
|
|
|
|
39
|
3 |
|
'form' => $form, |
40
|
3 |
|
'projects' => $this->auth->user()->projects()->get(), |
|
|
|
|
41
|
|
|
]); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* To update user settings |
46
|
|
|
* |
47
|
|
|
* @param FormRequest\UserSetting $request |
48
|
|
|
* |
49
|
|
|
* @return \Illuminate\Http\RedirectResponse |
50
|
|
|
*/ |
51
|
2 |
|
public function postSettings(FormRequest\UserSetting $request) |
52
|
|
|
{ |
53
|
2 |
|
$this->auth->user()->updateSetting($request->all()); |
|
|
|
|
54
|
|
|
|
55
|
2 |
|
return redirect('user/settings')->with('notice', trans('tinyissue.settings_updated')); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Shows the user's assigned issues |
60
|
|
|
* |
61
|
|
|
* @param string $display |
62
|
|
|
* @param Project $project |
63
|
|
|
* |
64
|
|
|
* @return \Illuminate\View\View |
65
|
|
|
*/ |
66
|
1 |
|
public function getIssues($display = 'list', Project $project = null) |
67
|
|
|
{ |
68
|
1 |
|
$view = $display === 'columns' ? 'columns' : 'list'; |
69
|
|
|
$data = [ |
70
|
1 |
|
'projects' => $this->auth->user()->projectsWidthIssues(Project::STATUS_OPEN)->get(), |
|
|
|
|
71
|
|
|
]; |
72
|
|
|
|
73
|
1 |
|
if ($display === 'columns') { |
74
|
|
|
$data['project'] = $project->find(1); |
|
|
|
|
75
|
|
|
$data['columns'] = $data['project']->kanbanTags()->get(); |
76
|
|
|
$ids = $data['columns']->lists('id')->all(); |
77
|
|
|
$issues = $data['project']->issues() |
78
|
|
|
->with('countComments', 'user', 'updatedBy', 'tags', 'tags.parent') |
79
|
|
|
->with([ |
80
|
|
|
'tags' => function (Relation $query) use ($ids) { |
81
|
|
|
$query->whereIn('id', $ids); |
82
|
|
|
}, |
83
|
|
|
]) |
84
|
|
|
->orderBy('id')->get(); |
85
|
|
|
|
86
|
|
|
$data['issues'] = $issues->groupBy(function (Project\Issue $issue) { |
87
|
|
|
return $issue->tags->last()->name; |
|
|
|
|
88
|
|
|
}); |
89
|
|
|
} |
90
|
|
|
|
91
|
1 |
|
return view('user.issues-' . $view, $data); |
|
|
|
|
92
|
|
|
} |
93
|
|
|
} |
94
|
|
|
|