mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 13:34:04 +00:00
wip
This commit is contained in:
commit
fd0712e037
2 changed files with 16 additions and 27 deletions
|
|
@ -6,20 +6,21 @@ use Illuminate\Database\Eloquent\Model;
|
|||
|
||||
class Tenant extends Model
|
||||
{
|
||||
public function getDataColumn()
|
||||
{
|
||||
return 'data';
|
||||
}
|
||||
protected $dataColumn = 'data';
|
||||
protected $specialColumns = [];
|
||||
protected $guarded = [];
|
||||
|
||||
public function put(string $key, $value)
|
||||
{
|
||||
if ($this->getConnection()->getSchemaBuilder()->hasColumn($this->getTable(), $key)) {
|
||||
if (array_key_exists($key, $this->specialColumns)) {
|
||||
$this->update([$key => $value]);
|
||||
} else {
|
||||
$obj = json_decode($this->{$this->getDataColumn()});
|
||||
$obj = json_decode($this->{$this->dataColumn});
|
||||
$obj->$key = $value;
|
||||
|
||||
$this->update([$this->getDataColumn() => json_encode($obj)]);
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue