diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 5452c708..7852ab20 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -40,7 +40,7 @@ jobs: run: | cd tests/integration composer remove phpunit/phpunit --dev - composer require pestphp/pest:^2.0 pestphp/pest-plugin-laravel:^2.0 pestphp/pest-plugin-drift:^2.0 --dev + composer require pestphp/pest:^2.0 pestphp/pest-plugin-laravel:^2.0 pestphp/pest-plugin-drift:^2.0 --dev -W vendor/bin/pest --init vendor/bin/pest --drift composer require livewire/livewire:^${{ matrix.livewire }} diff --git a/phpstan.neon.dist b/phpstan.neon.dist index c575bf67..c362c56f 100644 --- a/phpstan.neon.dist +++ b/phpstan.neon.dist @@ -9,7 +9,6 @@ parameters: level: 5 # The level 9 is the highest level ignoreErrors: [] excludePaths: [] - checkMissingIterableValueType: false scanFiles: - vendor/chinleung/laravel-locales/src/helpers.php scanDirectories: diff --git a/src/Models/Invitation.php b/src/Models/Invitation.php index e3696e6c..5e9ab269 100644 --- a/src/Models/Invitation.php +++ b/src/Models/Invitation.php @@ -20,11 +20,6 @@ class Invitation extends Model { use HasFactory; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'email', 'role', diff --git a/stubs/app/Http/Controllers/JoinController.php b/stubs/app/Http/Controllers/JoinController.php index 6b86e0fc..6d08db44 100644 --- a/stubs/app/Http/Controllers/JoinController.php +++ b/stubs/app/Http/Controllers/JoinController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers; +use App\Models\Organization; use App\Models\User; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; @@ -15,15 +16,16 @@ class JoinController extends Controller */ public function cancel(Request $request): RedirectResponse { + /** @var Organization */ $joinable = $request->user()->joinable; + flash(__('You have cancelled your request to join :team.', ['team' => $joinable->getTranslation('name', 'en')]), 'success'); + $request->user()->forceFill([ 'joinable_type' => null, 'joinable_id' => null, ])->save(); - flash(__('You have cancelled your request to join :team.', ['team' => $joinable->name]), 'success'); - return redirect(\localized_route($joinable->getRoutePrefix().'.show', $joinable)); } @@ -32,6 +34,7 @@ public function cancel(Request $request): RedirectResponse */ public function approve(Request $request, User $user): RedirectResponse { + /** @var Organization */ $joinable = $user->joinable; Gate::forUser($request->user())->authorize('update', $joinable); @@ -53,6 +56,7 @@ public function approve(Request $request, User $user): RedirectResponse */ public function deny(Request $request, User $user): RedirectResponse { + /** @var Organization */ $joinable = $user->joinable; Gate::forUser($request->user())->authorize('update', $joinable); diff --git a/stubs/app/Models/Organization.php b/stubs/app/Models/Organization.php index 722eaa4c..9745319e 100644 --- a/stubs/app/Models/Organization.php +++ b/stubs/app/Models/Organization.php @@ -24,31 +24,16 @@ class Organization extends Model use HasTranslations; use Notifiable; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'name', 'locality', 'region', ]; - /** - * The relationships that should be deleted when an organization is deleted. - * - * @var array - */ protected mixed $cascadeDeletes = [ 'users', ]; - /** - * The attributes that are translatable. - * - * @var array - */ public array $translatable = [ 'name', 'slug', diff --git a/stubs/app/Models/Resource.php b/stubs/app/Models/Resource.php index 619cec05..aff7658e 100644 --- a/stubs/app/Models/Resource.php +++ b/stubs/app/Models/Resource.php @@ -15,22 +15,12 @@ class Resource extends Model use HasTranslatableSlug; use HasTranslations; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'title', 'user_id', 'summary', ]; - /** - * The attributes that are translatable. - * - * @var array - */ public mixed $translatable = [ 'title', 'slug', diff --git a/stubs/app/Models/ResourceCollection.php b/stubs/app/Models/ResourceCollection.php index 082eadee..cbbfbc88 100644 --- a/stubs/app/Models/ResourceCollection.php +++ b/stubs/app/Models/ResourceCollection.php @@ -16,20 +16,12 @@ class ResourceCollection extends Model use HasTranslatableSlug; use HasTranslations; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'title', 'user_id', 'description', ]; - /** - * The attributes that are transterms - */ public array $translatable = [ 'title', 'slug', diff --git a/stubs/app/Models/User.php b/stubs/app/Models/User.php index cb31b575..89e7db58 100644 --- a/stubs/app/Models/User.php +++ b/stubs/app/Models/User.php @@ -24,11 +24,6 @@ class User extends Authenticatable implements HasLocalePreference, MustVerifyEma use Notifiable; use TwoFactorAuthenticatable; - /** - * The attributes that are mass assignable. - * - * @var array - */ protected $fillable = [ 'name', 'email', @@ -36,11 +31,6 @@ class User extends Authenticatable implements HasLocalePreference, MustVerifyEma 'locale', ]; - /** - * The attributes that should be hidden for arrays. - * - * @var array - */ protected $hidden = [ 'password', 'remember_token', @@ -48,20 +38,10 @@ class User extends Authenticatable implements HasLocalePreference, MustVerifyEma 'two_factor_secret', ]; - /** - * The attributes that should be cast to native types. - * - * @var array - */ protected $casts = [ 'email_verified_at' => 'datetime', ]; - /** - * The relationships that should be deleted when a user is deleted. - * - * @var array - */ protected mixed $cascadeDeletes = [ 'organizations', ]; @@ -123,7 +103,10 @@ public function joinable(): MorphTo */ public function hasRequestedToJoin(mixed $model) { - return $this->joinable && $this->joinable->id === $model->id; + /** @var Organization|null */ + $joinable = $this->joinable; + + return ! is_null($joinable) && $joinable->id === $model->id; } /** diff --git a/stubs/phpstan.neon.dist b/stubs/phpstan.neon.dist index e229f826..58885b37 100644 --- a/stubs/phpstan.neon.dist +++ b/stubs/phpstan.neon.dist @@ -20,4 +20,3 @@ parameters: - vendor/chinleung/laravel-locales/src/helpers.php ignoreErrors: [] - checkMissingIterableValueType: false