Skip to content

Commit

Permalink
Fix phpstan $this in Blueprint macro is falsly parsed (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Katalam authored Jan 18, 2023
2 parents 75fb081 + 74cfd2e commit b8dd5f1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/CreatedByServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,59 +25,69 @@ public function packageRegistered(): void
{
if (! Blueprint::hasMacro('createdBy')) {
Blueprint::macro('createdBy', function () {
/** @var Blueprint $this */
$this->foreignIdFor(config('auth.providers.users.model', User::class), 'created_by')
->nullable()
->default(null);
});
}
if (! Blueprint::hasMacro('updatedBy')) {
Blueprint::macro('updatedBy', function () {
/** @var Blueprint $this */
$this->foreignIdFor(config('auth.providers.users.model', User::class), 'updated_by')
->nullable()
->default(null);
});
}
if (! Blueprint::hasMacro('deletedBy')) {
Blueprint::macro('deletedBy', function () {
/** @var Blueprint $this */
$this->foreignIdFor(config('auth.providers.users.model', User::class), 'deleted_by')
->nullable()
->default(null);
});
}
if (! Blueprint::hasMacro('restoredBy')) {
Blueprint::macro('restoredBy', function () {
/** @var Blueprint $this */
$this->foreignIdFor(config('auth.providers.users.model', User::class), 'restored_by')
->nullable()
->default(null);
});
}
if (! Blueprint::hasMacro('restoredAt')) {
Blueprint::macro('restoredAt', function () {
/** @var Blueprint $this */
$this->timestamp('restored_at')->nullable()->default(null);
});
}
if (! Blueprint::hasMacro('dropCreatedBy')) {
Blueprint::macro('dropCreatedBy', function () {
/** @var Blueprint $this */
$this->dropColumn('created_by');
});
}
if (! Blueprint::hasMacro('dropUpdatedBy')) {
Blueprint::macro('dropUpdatedBy', function () {
/** @var Blueprint $this */
$this->dropColumn('updated_by');
});
}
if (! Blueprint::hasMacro('dropDeletedBy')) {
Blueprint::macro('dropDeletedBy', function () {
/** @var Blueprint $this */
$this->dropColumn('deleted_by');
});
}
if (! Blueprint::hasMacro('dropRestoredBy')) {
Blueprint::macro('dropRestoredBy', function () {
/** @var Blueprint $this */
$this->dropColumn('restored_by');
});
}
if (! Blueprint::hasMacro('dropRestoredAt')) {
Blueprint::macro('dropRestoredAt', function () {
/** @var Blueprint $this */
$this->dropColumn('restored_at');
});
}
Expand Down

0 comments on commit b8dd5f1

Please sign in to comment.