@feature blade directive don't get the current scope
elmarzouguidev opened this issue · comments
Pennant Version
1.2.1
Laravel Version
10.6
PHP Version
8.1
Database Driver & Version
No response
Description
class Tenant extends BaseTenant implements TenantWithDatabase
{
use HasDatabase, HasDomains;
use HasFeatures;
}
This is the Tenant model when I set HasFeatures trait
But when I'm login with my user that belongs to this tenant
it trows an error :
App\Providers\AppServiceProvider::App\Providers{closure}(): Argument #1 ($tenant) must be of type App\Models\Tenant, App\Models\User given, called in ...
BUT when i use @if in blade all things work normaly :
NOT WORK (throw the error above)
@feature('new-api)
@endfeature
WORK fine
@if(tenant()->features()->active('new-api'))
@endif
Steps To Reproduce
i dont know
this is the method boot in AppServiceProvider
public function boot(): void
{
Feature::define('new-api', function (Tenant $tenant) {
return $tenant->is_active;
});
}
Without clear steps to reproduce I'm afraid we cannot help. Please try a support channel:
Hi @elmarzouguidev,
This is likely because Pennant will use the "default" scope when checking Blade directives.
See the docs on how to configure the default scope: https://laravel.com/docs/10.x/pennant#default-scope
Otherwise, you are free to not use the Blade directive and just use
@if(tenant()->features()->active('new-api'))
as you already have working.
Thanks @timacdonald yes finaly i use @if blade directive