mirror of
https://github.com/archtechx/tenancy.git
synced 2025-12-12 12:24:04 +00:00
Fix asset publishing
This commit is contained in:
parent
4d6003eec0
commit
0508429e0f
7 changed files with 22 additions and 15 deletions
|
|
@ -45,7 +45,7 @@ class Install extends Command
|
|||
|
||||
$this->callSilent('vendor:publish', [
|
||||
'--provider' => 'Stancl\Tenancy\TenancyServiceProvider',
|
||||
'--tag' => 'provider',
|
||||
'--tag' => 'providers',
|
||||
]);
|
||||
$this->info('✔️ Created TenancyServiceProvider.php');
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,11 @@
|
|||
|
||||
namespace Stancl\Tenancy\Database\Concerns;
|
||||
|
||||
/**
|
||||
* This trait lets you add a "data" column functionality to any Eloquent model.
|
||||
* It serializes attributes which don't exist as columns on the model's table
|
||||
* into a JSON column named data (customizable by overriding getDataColumn).
|
||||
*/
|
||||
trait HasDataColumn
|
||||
{
|
||||
public static $priorityListeners = [];
|
||||
|
|
@ -118,4 +123,4 @@ trait HasDataColumn
|
|||
{
|
||||
return array_merge(['id'], config('tenancy.custom_columns'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,4 +13,15 @@ trait HasDomains
|
|||
{
|
||||
return $this->hasMany(config('tenancy.domain_model'), 'tenant_id');
|
||||
}
|
||||
|
||||
public function createDomain($data): Domain
|
||||
{
|
||||
$class = config('tenancy.domain_model');
|
||||
|
||||
$domain = (new $class)->fill($data);
|
||||
$domain->tenant()->associate($this);
|
||||
$domain->save();
|
||||
|
||||
return $domain;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ class Tenant extends Model implements Contracts\Tenant
|
|||
{
|
||||
use Concerns\CentralConnection,
|
||||
Concerns\GeneratesIds,
|
||||
Concerns\HasDataColumn {
|
||||
Concerns\HasDataColumn::getCasts as dataColumnCasts;
|
||||
}
|
||||
Concerns\HasDataColumn;
|
||||
|
||||
protected $table = 'tenants';
|
||||
protected $primaryKey = 'id';
|
||||
|
|
@ -44,13 +42,6 @@ class Tenant extends Model implements Contracts\Tenant
|
|||
return new TenantCollection($models);
|
||||
}
|
||||
|
||||
public function getCasts()
|
||||
{
|
||||
return array_merge($this->dataColumnCasts(), [
|
||||
'id' => $this->getIncrementing() ? 'integer' : 'string',
|
||||
]);
|
||||
}
|
||||
|
||||
public static function internalPrefix(): string
|
||||
{
|
||||
return config('tenancy.internal_prefix');
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class InitializeTenancyBySubdomain extends InitializeTenancyByDomain
|
|||
|
||||
// If we're on localhost or an IP address, then we're not visiting a subdomain.
|
||||
$notADomain = in_array(count($parts), [1, 4]);
|
||||
$thirdPartyDomain = ! Str::endsWith($hostname, config('tenancy.central_domains'));;
|
||||
$thirdPartyDomain = ! Str::endsWith($hostname, config('tenancy.central_domains'));
|
||||
|
||||
if ($notADomain || $thirdPartyDomain) {
|
||||
$handle = static::$onInvalidSubdomain ?? function ($e) {
|
||||
|
|
|
|||
|
|
@ -88,12 +88,12 @@ class TenancyServiceProvider extends ServiceProvider
|
|||
], 'migrations');
|
||||
|
||||
$this->publishes([
|
||||
__DIR__ . '/../assets/2020_05_15_000010_create_tenant_user_impersonation_tokens_table.php' => database_path('migrations'),
|
||||
__DIR__ . '/../assets/impersonation-migrations/' => database_path('migrations'),
|
||||
], 'impersonation-migrations');
|
||||
|
||||
$this->publishes([
|
||||
__DIR__ . '/../assets/TenancyServiceProvider.stub.php' => app_path('Providers/TenancyServiceProvider.php'),
|
||||
], 'migrations');
|
||||
], 'providers');
|
||||
|
||||
$this->loadRoutesFrom(__DIR__ . '/routes.php');
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue