如果你在非本地环境部署了 Filament 后台面板,访问后台时收到 403 Forbidden 错误 。可能是因为你忘记设置 User 模型了。
用户模型必须实现 FilamentUser
接口:
<?php
namespace App\Models;
use Filament\Models\Contracts\FilamentUser;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable implements FilamentUser
{
// ...
public function canAccessFilament(): bool
{
return str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail();
}
}