1 | <?php namespace Arcanedev\LaravelTracker\Trackers; |
||
13 | class UserTracker extends AbstractTracker implements UserTrackerContract |
||
14 | { |
||
15 | /* ----------------------------------------------------------------- |
||
16 | | Properties |
||
17 | | ----------------------------------------------------------------- |
||
18 | */ |
||
19 | |||
20 | /** @var array */ |
||
21 | private $auths = []; |
||
22 | |||
23 | /* ----------------------------------------------------------------- |
||
24 | | Constructor |
||
25 | | ----------------------------------------------------------------- |
||
26 | */ |
||
27 | |||
28 | /** |
||
29 | * UserTracker constructor. |
||
30 | * |
||
31 | * @param \Illuminate\Contracts\Foundation\Application $app |
||
32 | */ |
||
33 | 12 | public function __construct(Application $app) |
|
39 | |||
40 | /** |
||
41 | * Grab all the authentication bindings. |
||
42 | */ |
||
43 | 12 | private function instantiateAuthentication() |
|
44 | { |
||
45 | 12 | foreach ((array) $this->getConfig('auth.bindings', []) as $binding) { |
|
46 | 12 | $this->auths[] = $this->make($binding); |
|
47 | } |
||
48 | 12 | } |
|
49 | |||
50 | /* ----------------------------------------------------------------- |
||
51 | | Getters and Setters |
||
52 | | ----------------------------------------------------------------- |
||
53 | */ |
||
54 | |||
55 | /** |
||
56 | * Get the model. |
||
57 | * |
||
58 | * @return \Arcanedev\LaravelTracker\Models\User |
||
59 | */ |
||
60 | protected function getModel() |
||
64 | |||
65 | /* ----------------------------------------------------------------- |
||
66 | | Main Methods |
||
67 | | ----------------------------------------------------------------- |
||
68 | */ |
||
69 | |||
70 | /** |
||
71 | * Track the current authenticated user id. |
||
72 | * |
||
73 | * @return int|null |
||
74 | */ |
||
75 | 9 | public function track() |
|
76 | { |
||
77 | 9 | return $this->check() |
|
78 | ? $this->user()->{$this->getConfig('auth.columns.id', 'id')} |
||
79 | 9 | : null; |
|
80 | } |
||
81 | |||
82 | /* ----------------------------------------------------------------- |
||
83 | | Other Methods |
||
84 | | ----------------------------------------------------------------- |
||
85 | */ |
||
86 | |||
87 | /** |
||
88 | * Check if the user is authenticated. |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | 9 | protected function check() |
|
96 | |||
97 | /** |
||
98 | * Get the authenticated user. |
||
99 | * |
||
100 | * @return false|mixed |
||
101 | */ |
||
102 | protected function user() |
||
106 | |||
107 | /** |
||
108 | * Execute the auth method. |
||
109 | * |
||
110 | * @param string $method |
||
111 | * |
||
112 | * @return mixed|false |
||
113 | */ |
||
114 | 9 | private function executeAuthMethod($method) |
|
124 | } |
||
125 |