1
|
|
|
<?php namespace Arcanedev\LaravelTracker\Trackers; |
2
|
|
|
|
3
|
|
|
use Illuminate\Contracts\Foundation\Application; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class AbstractTracker |
7
|
|
|
* |
8
|
|
|
* @package Arcanedev\LaravelTracker\Trackers |
9
|
|
|
* @author ARCANEDEV <[email protected]> |
10
|
|
|
*/ |
11
|
|
|
abstract class AbstractTracker |
12
|
|
|
{ |
13
|
|
|
/* ------------------------------------------------------------------------------------------------ |
14
|
|
|
| Properties |
15
|
|
|
| ------------------------------------------------------------------------------------------------ |
16
|
|
|
*/ |
17
|
|
|
/** @var \Illuminate\Contracts\Foundation\Application */ |
18
|
|
|
private $app; |
19
|
|
|
|
20
|
|
|
/* ------------------------------------------------------------------------------------------------ |
21
|
|
|
| Constructor |
22
|
|
|
| ------------------------------------------------------------------------------------------------ |
23
|
|
|
*/ |
24
|
|
|
/** |
25
|
|
|
* AbstractTracker constructor. |
26
|
|
|
*/ |
27
|
156 |
|
public function __construct(Application $app) |
28
|
|
|
{ |
29
|
156 |
|
$this->app = $app; |
30
|
156 |
|
} |
31
|
|
|
|
32
|
|
|
/* ------------------------------------------------------------------------------------------------ |
33
|
|
|
| Common Functions |
34
|
|
|
| ------------------------------------------------------------------------------------------------ |
35
|
|
|
*/ |
36
|
|
|
/** |
37
|
|
|
* Get the config instance. |
38
|
|
|
* |
39
|
|
|
* @return \Illuminate\Contracts\Config\Repository |
40
|
|
|
*/ |
41
|
30 |
|
protected function config() |
42
|
|
|
{ |
43
|
30 |
|
return $this->make('config'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Get the session store instance. |
48
|
|
|
* |
49
|
|
|
* @return \Illuminate\Session\Store |
50
|
|
|
*/ |
51
|
12 |
|
protected function session() |
52
|
|
|
{ |
53
|
12 |
|
return $this->make('session.store'); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Get the tracker config. |
58
|
|
|
* |
59
|
|
|
* @param string $key |
60
|
|
|
* @param mixed|null $default |
61
|
|
|
* |
62
|
|
|
* @return mixed |
63
|
|
|
*/ |
64
|
30 |
|
protected function getConfig($key, $default = null) |
65
|
|
|
{ |
66
|
30 |
|
return $this->config()->get("laravel-tracker.$key", $default); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Make/Get the instance from the app. |
71
|
|
|
* |
72
|
|
|
* @param string $abstract |
73
|
|
|
* |
74
|
|
|
* @return mixed |
75
|
|
|
*/ |
76
|
66 |
|
protected function make($abstract) |
77
|
|
|
{ |
78
|
66 |
|
return $this->app->make($abstract); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|