filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
18.21k stars 2.85k forks source link

Create user error #6214

Closed BaraoVlask closed 1 year ago

BaraoVlask commented 1 year ago

Package

filament/filament

Package Version

v2.17.24

Laravel Version

v10.7.1

Livewire Version

v2.12.3

PHP Version

8.1

Problem description

Return type error Filament\Commands\MakeUserCommand::createUser(): Return value must be of type Illuminate\Contracts\Auth\Authenticatable, App\Models\User returned

Expected behavior

create a user without errors

Steps to reproduce

install laravel install filament run php artisan make:filament-user

Reproduction repository

https://github.com/no-need

Relevant log output

TypeError 

  Filament\Commands\MakeUserCommand::createUser(): Return value must be of type Illuminate\Contracts\Auth\Authenticatable, App\Models\User returned

  at vendor/filament/filament/src/Commands/MakeUserCommand.php:38
     34▕     }
     35▕ 
     36▕     protected function createUser(): Authenticatable
     37▕     {
  ➜  38▕         return static::getUserModel()::create($this->getUserData());
     39▕     }
     40▕ 
     41▕     protected function sendSuccessMessage(Authenticatable $user): void
     42▕     {

      +13 vendor frames 

  14  artisan:35
      Illuminate\Foundation\Console\Kernel::handle()
danharrin commented 1 year ago

As the error suggests, your user model does not implement the Authticatable interface as Laravel requires.

flashadvocate commented 4 months ago

As the error suggests, your user model does not implement the Authticatable interface as Laravel requires.

~This is out of the box behavior. Shouldn't this be mentioned in the setup documentation if it's a required preliminary step?~

Actually, I'm betting the OP is using blueprint to generate models, which replaces the built-in user, and does not include the correct stub.

@BaraoVlask compare your \App\Models\User model to the one that Laravel ships with by default. If you are using Blueprint, use this instead:

use Filament\Models\Contracts\FilamentUser;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements FilamentUser
{
// ...