@@ 16-135 (lines=120) @@ | ||
13 | use LaravelFlare\Flare\Http\Controllers\FlareController; |
|
14 | use LaravelFlare\Flare\Admin\Widgets\WidgetAdminManager; |
|
15 | ||
16 | class AdminController extends FlareController |
|
17 | { |
|
18 | use AuthenticatesUsers { |
|
19 | AuthenticatesUsers::redirectPath insteadof ResetsPasswords; |
|
20 | AuthenticatesUsers::getGuard insteadof ResetsPasswords; |
|
21 | } |
|
22 | use ResetsPasswords; |
|
23 | use ThrottlesLogins; |
|
24 | use DispatchesJobs; |
|
25 | ||
26 | /** |
|
27 | * Auth. |
|
28 | * |
|
29 | * @var Guard |
|
30 | */ |
|
31 | protected $auth; |
|
32 | ||
33 | /** |
|
34 | * __construct. |
|
35 | * |
|
36 | * @param Guard $auth |
|
37 | * @param AdminManager $adminManager |
|
38 | */ |
|
39 | public function __construct(Guard $auth, AdminManager $adminManager) |
|
40 | { |
|
41 | parent::__construct($adminManager); |
|
42 | ||
43 | $this->auth = $auth; |
|
44 | } |
|
45 | ||
46 | /** |
|
47 | * Show the Dashboard. |
|
48 | * |
|
49 | * @return \Illuminate\Http\Response |
|
50 | */ |
|
51 | public function getDashboard() |
|
52 | { |
|
53 | $view = 'admin.dashboard'; |
|
54 | ||
55 | if (!view()->exists($view)) { |
|
56 | $view = 'flare::'.$view; |
|
57 | } |
|
58 | ||
59 | return view($view, ['widgets' => (new WidgetAdminManager())]); |
|
60 | } |
|
61 | ||
62 | /** |
|
63 | * Show the login form. |
|
64 | * |
|
65 | * @return \Illuminate\Http\Response |
|
66 | */ |
|
67 | public function getLogin() |
|
68 | { |
|
69 | return view('flare::admin.login'); |
|
70 | } |
|
71 | ||
72 | /** |
|
73 | * Log the user. |
|
74 | * |
|
75 | * @return \Illuminate\Http\RedirectReponse |
|
76 | */ |
|
77 | public function getLogout() |
|
78 | { |
|
79 | $this->auth->logout(); |
|
80 | ||
81 | return redirect('/'); |
|
82 | } |
|
83 | ||
84 | /** |
|
85 | * Display the form to request a password reset link. |
|
86 | * |
|
87 | * @return \Illuminate\Http\Response |
|
88 | */ |
|
89 | public function getEmail() |
|
90 | { |
|
91 | return view('flare::admin.password'); |
|
92 | } |
|
93 | ||
94 | /** |
|
95 | * Display the form to request a password reset link. |
|
96 | * |
|
97 | * @return \Illuminate\Http\Response |
|
98 | */ |
|
99 | public function getReset() |
|
100 | { |
|
101 | return view('flare::admin.reset'); |
|
102 | } |
|
103 | ||
104 | /** |
|
105 | * Performs the login redirect action. |
|
106 | * |
|
107 | * If the authenticated user has admin permissions |
|
108 | * then they will be redirected into the admin |
|
109 | * panel. If they do no, they will be sent |
|
110 | * to the homepage of the website. |
|
111 | * |
|
112 | * @return \Illuminate\Http\RedirectReponse |
|
113 | */ |
|
114 | protected function loginRedirect() |
|
115 | { |
|
116 | if (Permissions::check()) { |
|
117 | return redirect()->intended(\Flare::adminUrl()); |
|
118 | } |
|
119 | ||
120 | return redirect('/'); |
|
121 | } |
|
122 | ||
123 | /** |
|
124 | * Method is called when the appropriate controller |
|
125 | * method is unable to be found or called. |
|
126 | * |
|
127 | * @param array $parameters |
|
128 | * |
|
129 | * @return \Illuminate\Http\Response |
|
130 | */ |
|
131 | public function missingMethod($parameters = array()) |
|
132 | { |
|
133 | return view('flare::admin.404', []); |
|
134 | } |
|
135 | } |
|
136 |
@@ 16-134 (lines=119) @@ | ||
13 | use LaravelFlare\Flare\Http\Controllers\FlareController; |
|
14 | use LaravelFlare\Flare\Admin\Widgets\WidgetAdminManager; |
|
15 | ||
16 | class AdminController extends FlareController |
|
17 | { |
|
18 | use AuthenticatesUsers, RegistersUsers { |
|
19 | AuthenticatesUsers::redirectPath insteadof RegistersUsers; |
|
20 | } |
|
21 | use ThrottlesLogins; |
|
22 | use RegistersUsers; |
|
23 | use DispatchesJobs; |
|
24 | ||
25 | /** |
|
26 | * Auth. |
|
27 | * |
|
28 | * @var Guard |
|
29 | */ |
|
30 | protected $auth; |
|
31 | ||
32 | /** |
|
33 | * __construct. |
|
34 | * |
|
35 | * @param Guard $auth |
|
36 | * @param AdminManager $adminManager |
|
37 | */ |
|
38 | public function __construct(Guard $auth, AdminManager $adminManager) |
|
39 | { |
|
40 | parent::__construct($adminManager); |
|
41 | ||
42 | $this->auth = $auth; |
|
43 | } |
|
44 | ||
45 | /** |
|
46 | * Show the Dashboard. |
|
47 | * |
|
48 | * @return \Illuminate\Http\Response |
|
49 | */ |
|
50 | public function getDashboard() |
|
51 | { |
|
52 | $view = 'admin.dashboard'; |
|
53 | ||
54 | if (!view()->exists($view)) { |
|
55 | $view = 'flare::'.$view; |
|
56 | } |
|
57 | ||
58 | return view($view, ['widgets' => (new WidgetAdminManager())]); |
|
59 | } |
|
60 | ||
61 | /** |
|
62 | * Show the login form. |
|
63 | * |
|
64 | * @return \Illuminate\Http\Response |
|
65 | */ |
|
66 | public function getLogin() |
|
67 | { |
|
68 | return view('flare::admin.login'); |
|
69 | } |
|
70 | ||
71 | /** |
|
72 | * Log the user. |
|
73 | * |
|
74 | * @return \Illuminate\Http\RedirectReponse |
|
75 | */ |
|
76 | public function getLogout() |
|
77 | { |
|
78 | $this->auth->logout(); |
|
79 | ||
80 | return redirect('/'); |
|
81 | } |
|
82 | ||
83 | /** |
|
84 | * Display the form to request a password reset link. |
|
85 | * |
|
86 | * @return \Illuminate\Http\Response |
|
87 | */ |
|
88 | public function getEmail() |
|
89 | { |
|
90 | return view('flare::admin.password'); |
|
91 | } |
|
92 | ||
93 | /** |
|
94 | * Display the form to request a password reset link. |
|
95 | * |
|
96 | * @return \Illuminate\Http\Response |
|
97 | */ |
|
98 | public function getReset() |
|
99 | { |
|
100 | return view('flare::admin.reset'); |
|
101 | } |
|
102 | ||
103 | /** |
|
104 | * Performs the login redirect action. |
|
105 | * |
|
106 | * If the authenticated user has admin permissions |
|
107 | * then they will be redirected into the admin |
|
108 | * panel. If they do no, they will be sent |
|
109 | * to the homepage of the website. |
|
110 | * |
|
111 | * @return \Illuminate\Http\RedirectReponse |
|
112 | */ |
|
113 | protected function loginRedirect() |
|
114 | { |
|
115 | if (Permissions::check()) { |
|
116 | return redirect()->intended(\Flare::adminUrl()); |
|
117 | } |
|
118 | ||
119 | return redirect('/'); |
|
120 | } |
|
121 | ||
122 | /** |
|
123 | * Method is called when the appropriate controller |
|
124 | * method is unable to be found or called. |
|
125 | * |
|
126 | * @param array $parameters |
|
127 | * |
|
128 | * @return \Illuminate\Http\Response |
|
129 | */ |
|
130 | public function missingMethod($parameters = array()) |
|
131 | { |
|
132 | return view('flare::admin.404', []); |
|
133 | } |
|
134 | } |
|
135 |