Typing of getOwnerRecord and Filament::getTenant()

I'm currently using larastan to make sure my code is clean and fully typed, but i find myself to have to do a lot of code comments to make sure the code is properly typed both for my editor and larastan. I'm talking about stuff like this:
->hidden(function (RelationManager $livewire) {
/** @var Product $product */
$product = $livewire->getOwnerRecord();
return $product->packages->count() < 2;
})
->hidden(function (RelationManager $livewire) {
/** @var Product $product */
$product = $livewire->getOwnerRecord();
return $product->packages->count() < 2;
})
and
Actions\CreateAction::make()
->hidden(function () {
/** @var Organization $organization */
$organization = Filament::getTenant();
Actions\CreateAction::make()
->hidden(function () {
/** @var Organization $organization */
$organization = Filament::getTenant();
is there any way to improve this, and be able to directly used Filament::getTenant and have it typed?
1 Reply
awcodes
awcodes4mo ago
Considering these are all variable I don’t think there’s a better way. getTenant() could be any model. So there’s no way for phpstan to automatically know without the hint.
Want results from more Discord servers?
Add your server