F
Filamentโ€ข2mo ago
warpig

500 server error after updating user model

i created a user on my production server
php artisan make:filament-user
php artisan make:filament-user
to let the admin sign in, then i implemented this code on my User model:
public function canAccessFilament(): bool

{

return str_ends_with($this->email, '@yourdomain.com')

&& $this->hasVerifiedEmail();

}
public function canAccessFilament(): bool

{

return str_ends_with($this->email, '@yourdomain.com')

&& $this->hasVerifiedEmail();

}
i had to change the class to abstract because i kept seeing this message from laravel extra intelisense:
PHP Fatal error: Class App\Models\User contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Filament\Models\Contracts\FilamentUser::canAccessPanel) in /var/www/html/coellobranding/app/Models/User.php on line 12
PHP Fatal error: Class App\Models\User contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Filament\Models\Contracts\FilamentUser::canAccessPanel) in /var/www/html/coellobranding/app/Models/User.php on line 12
so after pushing the changes to the server now there is a 500 server error response ๐Ÿ™‚
3 Replies
warpig
warpigโ€ข2mo ago
and yes, i did imported the class and implements FilamentUser, what did i missed? oh and logs show this:
Cannot instantiate abstract class App\Models\User
Cannot instantiate abstract class App\Models\User
awcodes
awcodesโ€ข2mo ago
Can you share the whole user model? Minus any business logic.
warpig
warpigโ€ข2mo ago
<?php

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Models\Post;
use Illuminate\Notifications\Notifiable;
use Filament\Models\Contracts\FilamentUser;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;

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

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

namespace App\Models;

// use Illuminate\Contracts\Auth\MustVerifyEmail;
use App\Models\Post;
use Illuminate\Notifications\Notifiable;
use Filament\Models\Contracts\FilamentUser;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;

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

public function canAccessPanel(Panel $panel): bool
{
return str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail();
}
}
this works? for now the method is not part of my codebase to allow the website to load correctly, that is why "yourdomain" is there forgot to import Panel, the error is gone ๐Ÿ˜ฎ
Want results from more Discord servers?
Add your server
More Posts