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
|
180 |
|
public function __construct(Application $app) |
28
|
|
|
{ |
29
|
180 |
|
$this->app = $app; |
30
|
180 |
|
} |
31
|
|
|
|
32
|
|
|
/* ------------------------------------------------------------------------------------------------ |
33
|
|
|
| Common Functions |
34
|
|
|
| ------------------------------------------------------------------------------------------------ |
35
|
|
|
*/ |
36
|
|
|
/** |
37
|
|
|
* Get the config instance. |
38
|
|
|
* |
39
|
|
|
* @return \Illuminate\Contracts\Config\Repository |
40
|
|
|
*/ |
41
|
100 |
|
protected function config() |
42
|
|
|
{ |
43
|
100 |
|
return $this->make('config'); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Get the session store instance. |
48
|
|
|
* |
49
|
|
|
* @return \Illuminate\Session\Store |
50
|
|
|
*/ |
51
|
18 |
|
protected function session() |
52
|
|
|
{ |
53
|
18 |
|
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
|
100 |
|
protected function getConfig($key, $default = null) |
65
|
|
|
{ |
66
|
100 |
|
return $this->config()->get("laravel-tracker.$key", $default); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Make the model. |
71
|
|
|
* |
72
|
|
|
* @param string $name |
73
|
|
|
* |
74
|
|
|
* @return mixed |
75
|
|
|
*/ |
76
|
82 |
|
protected function makeModel($name) |
77
|
|
|
{ |
78
|
82 |
|
return $this->make( |
79
|
82 |
|
$this->getConfig("models.$name") |
80
|
41 |
|
); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* Make/Get the instance from the app. |
85
|
|
|
* |
86
|
|
|
* @param string $abstract |
87
|
|
|
* |
88
|
|
|
* @return mixed |
89
|
|
|
*/ |
90
|
106 |
|
protected function make($abstract) |
91
|
|
|
{ |
92
|
106 |
|
return $this->app->make($abstract); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|