Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PetroGromovo's avatar

Why Pennant\Feature in laravel 11 is not called?

On laravel / filament site I use features and looking at https://laravel.com/docs/11.x/pennant I do in app/Providers/AppServiceProvider.php:

<?php

namespace App\Providers;

use App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Support\ServiceProvider;
use App\Models\User;
use Laravel\Pennant\Feature;
...

class AppServiceProvider extends ServiceProvider
{

    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
    ];

    /**
     * Register any application services.
     *
     * @return void
     */


    public function register()
    {
        ...
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Feature::define('isManagerLogged', function (User $user) {
            // THESE @ LINES NOT IN LOG
            \Log::info(' -1 $user->isManager()::');
            \Log::info($user->isManager());

            return $user->isManager();
        });
        Feature::define('isAdminLogged', function (User $user) {
            // THESE @ LINES NOT IN LOG
            \Log::info(' -1 $user->isAdmin()::');
            \Log::info($user->isAdmin());

            return $user->isAdmin();
        });

Model User has Authenticatable and some other traits:

<?php

namespace App\Models;

use Filament\Models\Contracts\FilamentUser;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Illuminate\Support\Facades\Storage;
use Laravel\Sanctum\HasApiTokens;
use Spatie\Permission\Traits\HasRoles;
use Filament\Models\Contracts\HasDefaultTenant;
use Filament\Models\Contracts\HasTenants;
use Filament\Panel;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
use Filament\Models\Contracts\HasAvatar;
use Jeffgreco13\FilamentBreezy\Traits\TwoFactorAuthenticatable;


class User extends Authenticatable implements FilamentUser, HasDefaultTenant, HasTenants, HasAvatar
{
    use HasApiTokens, TwoFactorAuthenticatable, HasFactory, Notifiable, TwoFactorAuthenticatable;
    use HasRoles;

    protected $table = 'users';
    protected $primaryKey = 'id';
    public $timestamps = true;

    ...

    public function isManager()
    { /
        return ( auth()->user()->can(ACCESS_PERMISSION_MANAGER_LABEL));
    }

    public function isAdmin()
        return ( auth()->user()->can(ACCESS_PERMISSION_ADMIN_LABEL));
    }
}

But using this feature in blade file as :

@feature('isAdminLogged')
isAdminLogged:: SOME COMTENT
@endfeature

I always see this block on my page, but no log lines from isManagerLogged and isAdminLogged feature definitions.

What is wrong ?

"laravel/framework": "^11.19",
"filament/filament": "^3.2-stable",

Thanks in advance!

0 likes
1 reply
PetroGromovo's avatar

I uploaded demo project with this issue on https://github.com/PetroGromovo/Laravel11Demo :

In app/Providers/AppServiceProvider.php defined 2 features In app/Models/User.php - 2 methods used in features. For simplicity they now just returns true. In resources/views/welcome.blade.php - using these features in blade file.

The task is the same : in home page changing return values in methods of the model to show/hide content inside of the block.

Please, take a look.

Thanks in advance!

Please or to participate in this conversation.