1 | <?php namespace Arcanedev\LaravelTracker\Trackers; |
||
13 | class UserTracker extends AbstractTracker implements UserTrackerContract |
||
14 | { |
||
15 | /* ------------------------------------------------------------------------------------------------ |
||
16 | | Properties |
||
17 | | ------------------------------------------------------------------------------------------------ |
||
18 | */ |
||
19 | /** @var array */ |
||
20 | private $auths = []; |
||
21 | |||
22 | /* ------------------------------------------------------------------------------------------------ |
||
23 | | Constructor |
||
24 | | ------------------------------------------------------------------------------------------------ |
||
25 | */ |
||
26 | /** |
||
27 | * UserTracker constructor. |
||
28 | * |
||
29 | * @param \Illuminate\Contracts\Foundation\Application $app |
||
30 | */ |
||
31 | 24 | public function __construct(Application $app) |
|
32 | { |
||
33 | 24 | parent::__construct($app); |
|
34 | |||
35 | 24 | $this->instantiateAuthentication(); |
|
36 | 24 | } |
|
37 | |||
38 | /** |
||
39 | * Grab all the authentication bindings. |
||
40 | */ |
||
41 | 24 | private function instantiateAuthentication() |
|
42 | { |
||
43 | 24 | foreach ((array) $this->getConfig('auth.bindings', []) as $binding) { |
|
44 | 24 | $this->auths[] = $this->make($binding); |
|
45 | 12 | } |
|
46 | 24 | } |
|
47 | |||
48 | /* ------------------------------------------------------------------------------------------------ |
||
49 | | Getters and Setters |
||
50 | | ------------------------------------------------------------------------------------------------ |
||
51 | */ |
||
52 | /** |
||
53 | * Get the model. |
||
54 | * |
||
55 | * @return \Arcanedev\LaravelTracker\Models\User |
||
56 | */ |
||
57 | protected function getModel() |
||
58 | { |
||
59 | return $this->makeModel(AbstractModel::MODEL_USER); |
||
60 | } |
||
61 | |||
62 | /* ------------------------------------------------------------------------------------------------ |
||
63 | | Main Functions |
||
64 | | ------------------------------------------------------------------------------------------------ |
||
65 | */ |
||
66 | /** |
||
67 | * Track the current authenticated user id. |
||
68 | * |
||
69 | * @return int|null |
||
70 | */ |
||
71 | 18 | public function track() |
|
77 | |||
78 | /* ------------------------------------------------------------------------------------------------ |
||
79 | | Other Functions |
||
80 | | ------------------------------------------------------------------------------------------------ |
||
81 | */ |
||
82 | /** |
||
83 | * Check if the user is authenticated. |
||
84 | * |
||
85 | * @return bool |
||
86 | */ |
||
87 | 18 | protected function check() |
|
91 | |||
92 | /** |
||
93 | * Get the authenticated user. |
||
94 | * |
||
95 | * @return false|mixed |
||
96 | */ |
||
97 | protected function user() |
||
101 | |||
102 | /** |
||
103 | * Execute the auth method. |
||
104 | * |
||
105 | * @param string $method |
||
106 | * |
||
107 | * @return mixed|false |
||
108 | */ |
||
109 | 18 | private function executeAuthMethod($method) |
|
119 | } |
||
120 |