admin user - trying to install filament 4 and create admin user

Hi - been wanting to have play with all the latest updates, have run into a silly issue - my users table I like to change so users always have a first name and last name for use later, when I try php artisan make:filament-user I’m unable to create a user obviously as it doesn’t match database values required, first name last name Tried vendor publish but not found what I need as yet - know I’ve done this before as dev work using filament I could add filament admin user after fresh migration and seeded users for testing all with first names and last names ? For production fine to set using domain but for dev work I want an admin user to access panels to build What have I missed ? Thanks in advance
Solution:
use tinker php artisan tinker ```bash...
Jump to solution
5 Replies
Solution
LeandroFerreira
use tinker php artisan tinker
User::create([
'first_name' => 'Test',
'last_name' => 'User'
'email' => '[email protected]',
'password' => 'password'
]);
User::create([
'first_name' => 'Test',
'last_name' => 'User'
'email' => '[email protected]',
'password' => 'password'
]);
MPGsKrieg
MPGsKriegOP3w ago
Thanks - will this set user as filament admin user though as same can be done via seeder ?
Dennis Koch
Dennis Koch3w ago
There is no such thing as a "Filament Admin User". Access to the panel is controlled via the canAccessPanel() method on the User model. The filament:user command is just a helper to create a user for the default user model.
MPGsKrieg
MPGsKriegOP3w ago
Ok thank you, its been a while, guess I was just overthinking it - thank you
MPGsKrieg
MPGsKriegOP3w ago
Thanks again for your help pointing me in the right direction - did a bit more digging - the admin panel wasn't being displayed due to the name property and was able to sort this using the HasName contract - as below in case anyone else runs into same issue. <?php namespace App\Models; use Filament\Models\Contracts\FilamentUser; use Filament\Panel; use Filament\Models\Contracts\HasName; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable implements FilamentUser, HasName { public function canAccessPanel(Panel $panel): bool { if ($panel->getId() === 'admin') { return str_ends_with($this->email, '@yourdomain.com') && $this->hasVerifiedEmail(); } return true; } public function getFilamentName(): string { return "{$this->firstname} {$this->lastname}"; } } @Dennis Koch - in case others run into same problem - tinker wasn't the solution as already had a seeder for user but user name was user - firstname and lastname so panel wouldn't render without the HasName along with your help of the canAccessPanel() - thanks again - really appreciated the quick response

Did you find this page helpful?