Total Complexity | 6 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
10 | class DatabaseConfiguration extends Model |
||
11 | { |
||
12 | use HasFactory; |
||
13 | |||
14 | protected $fillable = [ |
||
15 | 'ref', |
||
16 | 'name', |
||
17 | 'database', |
||
18 | 'configuration' |
||
19 | ]; |
||
20 | |||
21 | public function scopeConfiguredDatabase($query, mixed $ref) |
||
22 | { |
||
23 | return $query->where('ref', $ref); |
||
24 | } |
||
25 | |||
26 | public function setConfigurationAttribute($value) |
||
27 | { |
||
28 | if (!is_array($value)) { |
||
29 | $value = []; |
||
30 | } |
||
31 | |||
32 | $value = json_encode($value); |
||
33 | |||
34 | if (config('dynamicdatabaseconfig.hash', true)) { |
||
35 | return $this->attributes['configuration'] = Crypt::encryptString($value); |
||
36 | } |
||
37 | |||
38 | return $value; |
||
39 | } |
||
40 | |||
41 | public function getConfigurationAttribute($value) |
||
48 | } |
||
49 | } |
||
50 |