[phpStan] Illuminate\Database\Eloquent\Model::$id.

getting the error on phpstan level 2 only which drive me crazy!!!! the code is from
public function canAccessTenant(Model $tenant): bool
{
return $this->belongsToCompany($tenant);
}
public function canAccessTenant(Model $tenant): bool
{
return $this->belongsToCompany($tenant);
}
and I cant change the signiter of the function and adding Company|Model wont help! should phpstan with larastan recognize the default laravel model attributes like id?
includes:
- vendor/larastan/larastan/extension.neon

parameters:

paths:
- app/

# Level 9 is the highest level
#level: 7
level: 2

# ignoreErrors:
# - '#PHPDoc tag @var#'
#
# excludePaths:
# - ./*/*/FileToBeExcluded.php
#
# checkMissingIterableValueType: false
includes:
- vendor/larastan/larastan/extension.neon

parameters:

paths:
- app/

# Level 9 is the highest level
#level: 7
level: 2

# ignoreErrors:
# - '#PHPDoc tag @var#'
#
# excludePaths:
# - ./*/*/FileToBeExcluded.php
#
# checkMissingIterableValueType: false
4 Replies
Lara Zeus
Lara ZeusOP9mo ago
another area where I got the same error Filament::getTenant()?->id how I can define the type of the class? ofc adding: * @property int $id didnt help!
jaocero
jaocero9mo ago
I solve the getTenant issue in phpstan by assigning it to a variable like this:
/** @var \App\Models\Team|null $currentTenant */
$currentTenant = Filament::getTenant();
/** @var \App\Models\Team|null $currentTenant */
$currentTenant = Filament::getTenant();
Lara Zeus
Lara ZeusOP9mo ago
still the same for me, that is why I feel somthing else is wrong!
/** @var Company|Model|null $tenant */
$tenant = Filament::getTenant()?->id;
$builder->where($model->qualifyColumn('company_id'), $tenant);
/** @var Company|Model|null $tenant */
$tenant = Filament::getTenant()?->id;
$builder->where($model->qualifyColumn('company_id'), $tenant);
give me Access to an undefined property Illuminate\Database\Eloquent\Model::$id
No description
khairulazmi_
khairulazmi_8mo ago
did you find a workaround ?
Want results from more Discord servers?
Add your server