mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 00:14:05 +00:00
wip
This commit is contained in:
parent
bee7f34973
commit
01007c3be7
1 changed files with 17 additions and 2 deletions
|
|
@ -6,5 +6,20 @@ use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Tenant extends Model
|
class Tenant extends Model
|
||||||
{
|
{
|
||||||
// todo if not attribute exists in db, put into json data
|
public function getDataColumn()
|
||||||
}
|
{
|
||||||
|
return 'data';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function put(string $key, $value)
|
||||||
|
{
|
||||||
|
if ($this->getConnection()->getSchemaBuilder()->hasColumn($this->getTable(), $key)) {
|
||||||
|
$this->update([$key => $value]);
|
||||||
|
} else {
|
||||||
|
$obj = json_decode($this->{$this->getDataColumn()});
|
||||||
|
$obj->$key = $value;
|
||||||
|
|
||||||
|
$this->update([$this->getDataColumn() => json_encode($obj)]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue