F
Filament8mo ago
Eren

Production Error

I got an error after production. Whats the problem. Didnt get it.
PHP Fatal error: Could not check compatibility between App\Models\User::canAccessPanel(App\Models\Panel $panel): bool and Filament\Models\Contracts\FilamentUser::canAccessPanel(Filament\Panel $panel): bool, because class App\Models\Panel is not available in app/Models/User.php on line 17

In User.php line 17:

Could not check compatibility between App\Models\User::canAccessPanel(App\Models\Panel $panel): bool and Filament\Models\Contracts\FilamentUser::canAccess
Panel(Filament\Panel $panel): bool, because class App\Models\Panel is not available
PHP Fatal error: Could not check compatibility between App\Models\User::canAccessPanel(App\Models\Panel $panel): bool and Filament\Models\Contracts\FilamentUser::canAccessPanel(Filament\Panel $panel): bool, because class App\Models\Panel is not available in app/Models/User.php on line 17

In User.php line 17:

Could not check compatibility between App\Models\User::canAccessPanel(App\Models\Panel $panel): bool and Filament\Models\Contracts\FilamentUser::canAccess
Panel(Filament\Panel $panel): bool, because class App\Models\Panel is not available
Solution:
You didn't import Panel.
Jump to solution
8 Replies
Thijmen
Thijmen8mo ago
So what is your code in User Model?
Dennis Koch
Dennis Koch8mo ago
Sounds like you didn't import Panel
Eren
ErenOP8mo ago
<?php

namespace App\Models;

use Filament\Models\Contracts\FilamentUser;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable implements FilamentUser
{
use HasApiTokens, HasFactory, Notifiable;


public function canAccessPanel(Panel $panel): bool
{
return str_ends_with($this->email, '@excursionlands.com') && $this->hasVerifiedEmail();
}


/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];

/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];

/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
<?php

namespace App\Models;

use Filament\Models\Contracts\FilamentUser;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Laravel\Sanctum\HasApiTokens;

class User extends Authenticatable implements FilamentUser
{
use HasApiTokens, HasFactory, Notifiable;


public function canAccessPanel(Panel $panel): bool
{
return str_ends_with($this->email, '@excursionlands.com') && $this->hasVerifiedEmail();
}


/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $fillable = [
'name',
'email',
'password',
];

/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];

/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
Solution
Dennis Koch
Dennis Koch8mo ago
You didn't import Panel.
Eren
ErenOP8mo ago
import panel where exactly User model ? can you please share import code. thank you.
Dennis Koch
Dennis Koch8mo ago
I mean the use statement.
Eren
ErenOP8mo ago
I got it. I got it. Its change after v2. Couldnt realize. because i updated from v2.
Dennis Koch
Dennis Koch8mo ago
You need to import classes via use that you use.
Want results from more Discord servers?
Add your server