|null $data * @property \Illuminate\Support\Carbon|null $created_at * @property \Illuminate\Support\Carbon|null $updated_at */ class GeneralConfig extends Model { protected $fillable = ['data']; protected $casts = [ 'data' => 'array', ]; /** * Get the unique configuration row. * * @return self */ public static function current(): self { return static::query()->firstOrCreate([], ['data' => []]); } /** * Get a setting value from the JSON data. * * @param string $key Setting key. * @param mixed $default Value returned. * @return mixed */ public function get(string $key, mixed $default = null): mixed { return data_get($this->data, $key, $default); } /** * Set a setting value in the JSON data. * * @param string $key Setting key. * @param mixed $value Value to store. * @return self */ public function put(string $key, mixed $value): self { $data = $this->data ?? []; data_set($data, $key, $value); $this->data = $data; return $this; } }