1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-05 20:54:03 +00:00

Fix code style (php-cs-fixer)

This commit is contained in:
PHP CS Fixer 2022-07-22 07:28:16 +00:00
parent 095c2e1380
commit c6161f6997
8 changed files with 7 additions and 25 deletions

View file

@ -28,8 +28,6 @@ class ClearPendingTenants extends Command
/** /**
* Execute the console command. * Execute the console command.
*
* @return mixed
*/ */
public function handle() public function handle()
{ {
@ -50,7 +48,6 @@ class ClearPendingTenants extends Command
} }
} }
$deletedPendingCount = tenancy() $deletedPendingCount = tenancy()
->query() ->query()
->onlyPending() ->onlyPending()

View file

@ -24,8 +24,6 @@ class CreatePendingTenants extends Command
/** /**
* Execute the console command. * Execute the console command.
*
* @return mixed
*/ */
public function handle() public function handle()
{ {
@ -53,8 +51,6 @@ class CreatePendingTenants extends Command
/** /**
* Calculate the number of currently deployed pending tenants. * Calculate the number of currently deployed pending tenants.
*
* @return int
*/ */
private function getPendingTenantCount(): int private function getPendingTenantCount(): int
{ {

View file

@ -12,7 +12,7 @@ trait HasATenantsOption
protected function getOptions() protected function getOptions()
{ {
return array_merge([ return array_merge([
['tenants', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_OPTIONAL, '', null], ['tenants', null, InputOption::VALUE_IS_ARRAY|InputOption::VALUE_OPTIONAL, '', null],
['with-pending', null, InputOption::VALUE_NONE, 'include pending tenants in query', null], ['with-pending', null, InputOption::VALUE_NONE, 'include pending tenants in query', null],
], parent::getOptions()); ], parent::getOptions());
} }

View file

@ -5,10 +5,10 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Database\Concerns; namespace Stancl\Tenancy\Database\Concerns;
use Stancl\Tenancy\Contracts\Tenant; use Stancl\Tenancy\Contracts\Tenant;
use Stancl\Tenancy\Events\PullingPendingTenant;
use Stancl\Tenancy\Events\PendingTenantPulled;
use Stancl\Tenancy\Events\CreatingPendingTenant; use Stancl\Tenancy\Events\CreatingPendingTenant;
use Stancl\Tenancy\Events\PendingTenantCreated; use Stancl\Tenancy\Events\PendingTenantCreated;
use Stancl\Tenancy\Events\PendingTenantPulled;
use Stancl\Tenancy\Events\PullingPendingTenant;
/** /**
* @property $pending_since * @property $pending_since
@ -39,7 +39,6 @@ trait HasPending
$this->casts['pending_since'] = 'timestamp'; $this->casts['pending_since'] = 'timestamp';
} }
/** /**
* Determine if the model instance is in a pending state. * Determine if the model instance is in a pending state.
* *
@ -59,7 +58,7 @@ trait HasPending
// Add the pending value only after creating the model // Add the pending value only after creating the model
// To ensure it's not marked as pending until finishing running the migrations, seeders, etc. // To ensure it's not marked as pending until finishing running the migrations, seeders, etc.
$tenant->update([ $tenant->update([
'pending_since' => now()->timestamp 'pending_since' => now()->timestamp,
]); ]);
event(new PendingTenantCreated($tenant)); event(new PendingTenantCreated($tenant));
@ -80,7 +79,7 @@ trait HasPending
event(new PullingPendingTenant($tenant)); event(new PullingPendingTenant($tenant));
$tenant->update([ $tenant->update([
'pending_since' => null 'pending_since' => null,
]); ]);
event(new PendingTenantPulled($tenant)); event(new PendingTenantPulled($tenant));

View file

@ -10,7 +10,6 @@ use Illuminate\Database\Eloquent\Scope;
class PendingScope implements Scope class PendingScope implements Scope
{ {
/** /**
* All of the extensions to be added to the builder. * All of the extensions to be added to the builder.
* *
@ -21,13 +20,11 @@ class PendingScope implements Scope
/** /**
* Apply the scope to a given Eloquent query builder. * Apply the scope to a given Eloquent query builder.
* *
* @param Builder $builder
* @param Model $model
* @return void * @return void
*/ */
public function apply(Builder $builder, Model $model) public function apply(Builder $builder, Model $model)
{ {
$builder->when(! config('tenancy.pending.include_in_queries'), function (Builder $builder){ $builder->when(! config('tenancy.pending.include_in_queries'), function (Builder $builder) {
$builder->whereNull('data->pending_since'); $builder->whereNull('data->pending_since');
}); });
} }
@ -35,7 +32,6 @@ class PendingScope implements Scope
/** /**
* Extend the query builder with the needed functions. * Extend the query builder with the needed functions.
* *
* @param \Illuminate\Database\Eloquent\Builder $builder
* @return void * @return void
*/ */
public function extend(Builder $builder) public function extend(Builder $builder)
@ -47,7 +43,6 @@ class PendingScope implements Scope
/** /**
* Add the with-pending extension to the builder. * Add the with-pending extension to the builder.
* *
* @param \Illuminate\Database\Eloquent\Builder $builder
* @return void * @return void
*/ */
protected function addWithPending(Builder $builder) protected function addWithPending(Builder $builder)
@ -64,13 +59,11 @@ class PendingScope implements Scope
/** /**
* Add the without-pending extension to the builder. * Add the without-pending extension to the builder.
* *
* @param \Illuminate\Database\Eloquent\Builder $builder
* @return void * @return void
*/ */
protected function addWithoutPending(Builder $builder) protected function addWithoutPending(Builder $builder)
{ {
$builder->macro('withoutPending', function (Builder $builder) { $builder->macro('withoutPending', function (Builder $builder) {
$builder->withoutGlobalScope($this) $builder->withoutGlobalScope($this)
->whereNull('data->pending_since') ->whereNull('data->pending_since')
->orWhereNull('data'); ->orWhereNull('data');
@ -82,7 +75,6 @@ class PendingScope implements Scope
/** /**
* Add the only-pending extension to the builder. * Add the only-pending extension to the builder.
* *
* @param \Illuminate\Database\Eloquent\Builder $builder
* @return void * @return void
*/ */
protected function addOnlyPending(Builder $builder) protected function addOnlyPending(Builder $builder)

View file

@ -10,7 +10,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Stancl\Tenancy\Contracts\TenantWithDatabase;
class ClearPendingTenants implements ShouldQueue class ClearPendingTenants implements ShouldQueue
{ {

View file

@ -10,7 +10,6 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels; use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Artisan;
use Stancl\Tenancy\Contracts\TenantWithDatabase;
class CreatePendingTenants implements ShouldQueue class CreatePendingTenants implements ShouldQueue
{ {

View file

@ -135,7 +135,7 @@ class Tenancy
{ {
$query = $this->model()->newQuery(); $query = $this->model()->newQuery();
if (is_bool($withPending) && $this->model()::hasGlobalScope(PendingScope::class)){ if (is_bool($withPending) && $this->model()::hasGlobalScope(PendingScope::class)) {
$query->withPending($withPending); $query->withPending($withPending);
} }
// Convert null to all tenants // Convert null to all tenants