1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Http\Requests; |
6
|
|
|
use Illuminate\Http\Request; |
7
|
|
|
|
8
|
|
|
use Bouncer; |
9
|
|
|
use Charts; |
10
|
|
|
|
11
|
|
|
class HomeController extends Controller |
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* Create a new controller instance. |
15
|
|
|
*/ |
16
|
|
|
public function __construct() |
17
|
|
|
{ |
18
|
|
|
$this->middleware('auth'); |
19
|
|
|
$this->middleware('lang'); |
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Show the application dashboard. |
24
|
|
|
* |
25
|
|
|
* @return \Illuminate\Http\Response |
26
|
|
|
*/ |
27
|
|
View Code Duplication |
public function index() |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
$user = auth()->user(); |
|
|
|
|
30
|
|
|
|
31
|
|
|
if(Bouncer::is($user)->a('Administrator', 'Manager')) { |
32
|
|
|
return redirect()->route('dashboard.administration'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
elseif(Bouncer::is($user)->an('Agent')) { |
36
|
|
|
return redirect()->route('dashboard.agent'); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
elseif(Bouncer::is($user)->an('Customer')) { |
40
|
|
|
return redirect('/'); |
41
|
|
|
} |
42
|
|
|
return redirect('/'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Show the administration dashboard. |
47
|
|
|
* |
48
|
|
|
* @return \Illuminate\Http\Response |
49
|
|
|
*/ |
50
|
|
|
public function administration() |
51
|
|
|
{ |
52
|
|
|
|
53
|
|
|
if (\Auth::check()) { |
54
|
|
|
// The user is logged in... |
55
|
|
|
|
56
|
|
|
$data["chart"] = Charts::create('percentage', 'justgage') |
|
|
|
|
57
|
|
|
->setTitle('') |
58
|
|
|
->setElementLabel('Open requests') |
59
|
|
|
->setValues([1,0,2]) |
60
|
|
|
->setResponsive(false) |
61
|
|
|
->setHeight(250) |
62
|
|
|
->setWidth(0); |
63
|
|
|
|
64
|
|
|
$data["overdue"] = Charts::create('percentage', 'justgage') |
65
|
|
|
->setElementLabel('Overdue requests') |
66
|
|
|
->setValues([65,0,100]) |
67
|
|
|
->setResponsive(false) |
68
|
|
|
->setHeight(300) |
69
|
|
|
->setWidth(0); |
70
|
|
|
|
71
|
|
|
$data["assigned"] = Charts::create('percentage', 'justgage') |
72
|
|
|
->setTitle('') |
73
|
|
|
->setElementLabel('Tasks assigned') |
74
|
|
|
->setValues([10, 0, 2]) |
75
|
|
|
->setResponsive(false) |
76
|
|
|
->setHeight(250) |
77
|
|
|
->setWidth(0); |
78
|
|
|
|
79
|
|
|
return view('home/administration', $data); |
80
|
|
|
|
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Show the administration dashboard. |
86
|
|
|
* |
87
|
|
|
* @return \Illuminate\Http\Response |
88
|
|
|
*/ |
89
|
|
|
public function agent() |
90
|
|
|
{ |
91
|
|
|
|
92
|
|
|
if (\Auth::check()) { |
93
|
|
|
// The user is logged in... |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
return view('home/agent'); |
97
|
|
|
|
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
} |
102
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.