rupadana / filament-api-service

A simple api service for supporting filamentphp
https://filamentphp.com/plugins/rupadana-api-service
MIT License
95 stars 22 forks source link

[Enhancement]: use $tenantModel->getRouteKeyName() instead of $tenantModel->getKeyName() #61

Open eelco2k opened 1 week ago

eelco2k commented 1 week ago

What happened?

in HasHandlerTenantScope.php it's better to use getRouteKeyName() instead of ->getKeyName()

because if you want for security reasons want the "tenant" to have an UUID instead of an ID you can override the getRouteKeyName() in the Tenant Model, that way it will be used in all URLs and as the tenantID in filament is also an url attribute http://somedomain.com/admin/{tenant}/ it would be better to use the getRouteKeyName().

in Illuminate\Database\Eloquent\Model getRouteKeyName() returns also $this->getKeyName();

so it should fallback nicely.

 $tenant = $tenantModel::where(Filament::getCurrentPanel()->getTenantSlugAttribute() ?? $tenantModel->getRouteKeyName(), $tenantId)->first()

How to reproduce the bug

uuid as route

Package Version

latest

PHP Version

8.3

Laravel Version

10

Which operating systems does with happen with?

No response

Notes

No response