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
|
|
|
|
18
|
|
|
/** @var \Illuminate\Contracts\Foundation\Application */ |
19
|
|
|
private $app; |
20
|
|
|
|
21
|
|
|
/* ----------------------------------------------------------------- |
22
|
|
|
| Constructor |
23
|
|
|
| ----------------------------------------------------------------- |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* AbstractTracker constructor. |
28
|
|
|
* |
29
|
|
|
* @param \Illuminate\Contracts\Foundation\Application $app |
30
|
|
|
*/ |
31
|
90 |
|
public function __construct(Application $app) |
32
|
|
|
{ |
33
|
90 |
|
$this->app = $app; |
34
|
90 |
|
} |
35
|
|
|
|
36
|
|
|
/* ----------------------------------------------------------------- |
37
|
|
|
| Common Methods |
38
|
|
|
| ----------------------------------------------------------------- |
39
|
|
|
*/ |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Get the config instance. |
43
|
|
|
* |
44
|
|
|
* @return \Illuminate\Contracts\Config\Repository |
45
|
|
|
*/ |
46
|
54 |
|
protected function config() |
47
|
|
|
{ |
48
|
54 |
|
return $this->make('config'); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* Get the session store instance. |
53
|
|
|
* |
54
|
|
|
* @return \Illuminate\Session\Store |
55
|
|
|
*/ |
56
|
9 |
|
protected function session() |
57
|
|
|
{ |
58
|
9 |
|
return $this->make('session.store'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Get the tracker config. |
63
|
|
|
* |
64
|
|
|
* @param string $key |
65
|
|
|
* @param mixed|null $default |
66
|
|
|
* |
67
|
|
|
* @return mixed |
68
|
|
|
*/ |
69
|
54 |
|
protected function getConfig($key, $default = null) |
70
|
|
|
{ |
71
|
54 |
|
return $this->config()->get("laravel-tracker.$key", $default); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Make the model. |
76
|
|
|
* |
77
|
|
|
* @param string $name |
78
|
|
|
* |
79
|
|
|
* @return \Illuminate\Database\Eloquent\Model|mixed |
80
|
|
|
*/ |
81
|
45 |
|
protected function makeModel($name) |
82
|
|
|
{ |
83
|
45 |
|
return $this->make( |
84
|
45 |
|
$this->getConfig("models.$name") |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Make/Get the instance from the app. |
90
|
|
|
* |
91
|
|
|
* @param string $abstract |
92
|
|
|
* |
93
|
|
|
* @return mixed |
94
|
|
|
*/ |
95
|
57 |
|
protected function make($abstract) |
96
|
|
|
{ |
97
|
57 |
|
return $this->app->make($abstract); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|