Bristol SU Support Package
ModuleInstanceSetting.php
Go to the documentation of this file.
1 <?php
2 
4 
8 
12 class ModuleInstanceSetting extends Model
13 {
14  use HasRevisions;
15 
21  protected $fillable = [
22  'key', 'value', 'module_instance_id', 'encoded'
23  ];
24 
30  public function moduleInstance()
31  {
32  return $this->belongsTo(ModuleInstance::class);
33  }
34 
40  public function setValueAttribute($value)
41  {
42  if (is_array($value)) {
43  $this->attributes['value'] = json_encode($value);
44  $this->attributes['encoded'] = true;
45  } else {
46  $this->attributes['value'] = $value;
47  }
48  }
49 
55  public function getValueAttribute()
56  {
57  if (($this->attributes['encoded']??false)) {
58  return json_decode($this->attributes['value'], true);
59  }
60  return $this->attributes['value'];
61  }
62 }