1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Helldar\Roles\Support; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Config as IlluminateConfig; |
6
|
|
|
|
7
|
|
|
class Config |
8
|
|
|
{ |
9
|
|
|
public const NAME = 'roles'; |
10
|
|
|
|
11
|
138 |
|
public function get($key, $default = null) |
12
|
|
|
{ |
13
|
138 |
|
return IlluminateConfig::get($this->compileKey($key), $default); |
14
|
|
|
} |
15
|
|
|
|
16
|
54 |
|
public function set($key, $value): void |
17
|
|
|
{ |
18
|
54 |
|
IlluminateConfig::set($this->compileKey($key), $value); |
19
|
54 |
|
} |
20
|
|
|
|
21
|
138 |
|
public function name(): string |
22
|
|
|
{ |
23
|
138 |
|
return static::NAME; |
24
|
|
|
} |
25
|
|
|
|
26
|
138 |
|
public function connection(): string |
27
|
|
|
{ |
28
|
138 |
|
return $this->get('connection', 'mysql'); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function useBlade(): bool |
32
|
|
|
{ |
33
|
|
|
return (bool) $this->get('use_blade', false); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function useCanDirective(): bool |
37
|
|
|
{ |
38
|
|
|
return (bool) $this->get('use_can_directive', false); |
39
|
|
|
} |
40
|
|
|
|
41
|
138 |
|
public function useCache(): bool |
42
|
|
|
{ |
43
|
138 |
|
return (bool) $this->get('use_cache', false); |
44
|
|
|
} |
45
|
|
|
|
46
|
6 |
|
public function cacheTtl(): int |
47
|
|
|
{ |
48
|
6 |
|
return (int) $this->get('cache_ttl', 3600); |
49
|
|
|
} |
50
|
|
|
|
51
|
138 |
|
public function filename() |
52
|
|
|
{ |
53
|
138 |
|
return $this->name() . '.php'; |
54
|
|
|
} |
55
|
|
|
|
56
|
6 |
|
public function defaultRole(): ?string |
57
|
|
|
{ |
58
|
6 |
|
return $this->get('default_role'); |
59
|
|
|
} |
60
|
|
|
|
61
|
138 |
|
protected function compileKey($key): string |
62
|
|
|
{ |
63
|
138 |
|
return $this->name() . '.' . $key; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|