1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Containers\Authentication\UI\Web\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Containers\Authentication\Actions\WebAdminLoginAction; |
6
|
|
|
use App\Containers\Authentication\Actions\WebLogoutAction; |
7
|
|
|
use App\Containers\Authentication\Exceptions\AuthenticationFailedException; |
8
|
|
|
use App\Containers\Authentication\UI\Web\Requests\LoginRequest; |
9
|
|
|
use App\Containers\Authentication\UI\Web\Requests\ViewDashboardRequest; |
10
|
|
|
use App\Port\Controller\Abstracts\PortWebController; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class Controller |
14
|
|
|
* |
15
|
|
|
* @author Mahmoud Zalt <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
class Controller extends PortWebController |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
22
|
|
|
*/ |
23
|
|
|
public function showLoginPage() |
24
|
|
|
{ |
25
|
|
|
return view('login'); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @param \App\Containers\Authentication\UI\Web\Requests\LoginRequest $request |
30
|
|
|
* @param \App\Containers\Authentication\Actions\WebAdminLoginAction $action |
31
|
|
|
* |
32
|
|
|
* @return $this|\Illuminate\Contracts\View\Factory|\Illuminate\View\View |
33
|
|
|
*/ |
34
|
|
|
public function loginAdmin(LoginRequest $request, WebAdminLoginAction $action) |
35
|
|
|
{ |
36
|
|
|
try { |
37
|
|
|
$result = $action->run($request->email, $request->password, $request->remember_me); |
|
|
|
|
38
|
|
|
} catch (AuthenticationFailedException $e) { |
39
|
|
|
return redirect('login')->with('status', $e->getMessage()); |
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
if (is_array($result)) { |
43
|
|
|
return view('login')->with($result); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
return redirect('dashboard'); |
|
|
|
|
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param \App\Containers\Authentication\UI\Web\Requests\ViewDashboardRequest $request |
51
|
|
|
* |
52
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
53
|
|
|
*/ |
54
|
|
|
public function viewDashboardPage(ViewDashboardRequest $request) |
|
|
|
|
55
|
|
|
{ |
56
|
|
|
return view('dashboard'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @param \App\Containers\Authentication\Actions\WebLogoutAction $action |
61
|
|
|
* |
62
|
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View |
63
|
|
|
*/ |
64
|
|
|
public function logoutAdmin(WebLogoutAction $action) |
65
|
|
|
{ |
66
|
|
|
$loggedOut = $action->run(); |
|
|
|
|
67
|
|
|
|
68
|
|
|
return view('login'); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
} |
73
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.