mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 22:34:05 +00:00
Apply fixes from StyleCI
This commit is contained in:
parent
bee7f34973
commit
adb92d5a9a
2 changed files with 5 additions and 2 deletions
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Stancl\Tenancy\StorageDrivers;
|
||||
|
||||
use Stancl\Tenancy\Interfaces\StorageDriver;
|
||||
use Stancl\Tenancy\Tenant;
|
||||
use Stancl\Tenancy\Interfaces\StorageDriver;
|
||||
|
||||
class DatabaseStorageDriver implements StorageDriver
|
||||
{
|
||||
|
|
@ -70,6 +70,7 @@ class DatabaseStorageDriver implements StorageDriver
|
|||
public function get(string $uuid, string $key)
|
||||
{
|
||||
$tenant = Tenant::find($uuid);
|
||||
|
||||
return $tenant->$key ?? json_decode($tenant->data)[$key] ?? null;
|
||||
}
|
||||
|
||||
|
|
@ -80,11 +81,13 @@ class DatabaseStorageDriver implements StorageDriver
|
|||
$tenant_data = null; // cache - json_decode() can be expensive
|
||||
$get_from_tenant_data = function ($key) use ($tenant, &$tenant_data) {
|
||||
$tenant_data = $tenant_data ?? json_decode($tenant->data);
|
||||
|
||||
return $tenant_data[$key] ?? null;
|
||||
};
|
||||
|
||||
return array_reduce($keys, function ($keys, $key) use ($tenant, $get_from_tenant_data) {
|
||||
$keys[$key] = $tenant->$key ?? $get_from_tenant_data($key) ?? null;
|
||||
|
||||
return $keys;
|
||||
}, []);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,4 +7,4 @@ use Illuminate\Database\Eloquent\Model;
|
|||
class Tenant extends Model
|
||||
{
|
||||
// todo if not attribute exists in db, put into json data
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue