mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 17:04:03 +00:00
Apply fixes suggested by @carlos-mora
This commit is contained in:
parent
429b1779f5
commit
f073926cfb
3 changed files with 11 additions and 7 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Stancl\Tenancy\StorageDrivers;
|
||||
|
||||
use Stancl\Tenancy\Interfaces\TenantModel;
|
||||
use Stancl\Tenancy\Tenant;
|
||||
use Stancl\Tenancy\Interfaces\StorageDriver;
|
||||
|
||||
class DatabaseStorageDriver implements StorageDriver
|
||||
|
|
@ -50,9 +50,13 @@ class DatabaseStorageDriver implements StorageDriver
|
|||
|
||||
public function getAllTenants(array $uuids = []): array
|
||||
{
|
||||
return Tenant::all()->map(function ($model) {
|
||||
return $model->toArray();
|
||||
})->toArray();
|
||||
if ($uuids) {
|
||||
$tenants = Tenant::find($uuids);
|
||||
} else {
|
||||
$tenants = Tenant::all();
|
||||
}
|
||||
|
||||
return $tenants->toArray();
|
||||
}
|
||||
|
||||
public function get(string $uuid, string $key)
|
||||
|
|
|
|||
|
|
@ -20,12 +20,12 @@ class Tenant extends Model
|
|||
|
||||
public function dataColumn()
|
||||
{
|
||||
return config('tenancy.db_storage.data_column');
|
||||
return config('tenancy.db_storage.data_column', 'data');
|
||||
}
|
||||
|
||||
public function customColumns()
|
||||
{
|
||||
return config('tenancy.db_storage.custom_columns');
|
||||
return config('tenancy.db_storage.custom_columns', []);
|
||||
}
|
||||
|
||||
public function getFromData(string $key)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class CreateTenantsTable extends Migration
|
|||
Schema::create('tenants', function (Blueprint $table) {
|
||||
$table->string('uuid', 36)->primary();
|
||||
$table->string('domain', 255)->index();
|
||||
$table->string('data', 1024)->default('{}');
|
||||
$table->json('data')->default('{}');
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue