Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't install Voyager "@php artisan package:discover --ansi " #5027

Closed
esponges opened this issue Jul 29, 2020 · 7 comments
Closed

Can't install Voyager "@php artisan package:discover --ansi " #5027

esponges opened this issue Jul 29, 2020 · 7 comments
Labels

Comments

@esponges
Copy link

esponges commented Jul 29, 2020

Hey guys,

Recently discovered this wonderfull package and I had no problems with it until now.

Version information

  • Laravel: v 7.22.4
  • Voyager: NA
  • PHP: 7.3.12
  • Database: [phpmyadmin] [4.9]

Description

Trying to install it in a new project would throw me this error

Call to undefined method Illuminate\Auth\DatabaseUserProvider::getModel()

at C:\xampp\htdocs\laravel\Veachy backs\Veachy (voyager admin)\vendor\tcg\voyager\src\VoyagerServiceProvider.php:101
     97|      */
     98|     public function boot(Router $router, Dispatcher $event)
     99|     {
    100|         if (config('voyager.user.add_default_role_on_register')) {
  > 101|             $model = Auth::guard(app('VoyagerGuard'))->getProvider()->getModel();
    102|             call_user_func($model.'::created', function ($user) use ($model) {
    103|                 if (is_null($user->role_id)) {
    104|                     call_user_func($model.'::findOrFail', $user->id)
    105|                         ->setRole(config('voyager.user.default_role'))

  1   C:\xampp\htdocs\laravel\Veachy backs\Veachy (voyager admin)\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:37
      TCG\Voyager\VoyagerServiceProvider::boot(Object(Illuminate\Routing\Router), Object(Illuminate\Events\Dispatcher))

  2   C:\xampp\htdocs\laravel\Veachy backs\Veachy (voyager admin)\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php:37
      call_user_func_array()
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

This error will prevail in any next php artisan command, untill I remove the package.

Before this error I was required to update composer memory from 512M to 2G. Don't know if it related.

Thanks all,

Fernando

@ousid
Copy link
Contributor

ousid commented Jul 30, 2020

you can find voyager package version in composer.json

can you provide the User.php Model? or you can try to clear cache by php artisan cache:config or delete the files packages.php and services.php from bootstrap/cache

@esponges
Copy link
Author

esponges commented Jul 31, 2020

Hey, thanks for the quick response.

My user model is the default User model. I haven't added any relationship or anything else yet to it.

Tried installing 1.3 package with same results. So strange...

`class User extends Authenticatable
{
    use Notifiable;

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

    /**
     * The attributes that should be hidden for arrays.
     *
     * @var array
     */
    protected $hidden = [
        'password', 'remember_token',
    ];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [
        'email_verified_at' => 'datetime',
    ];

Also tried

can you provide the User.php Model? or you can try to clear cache by php artisan cache:config or delete the files packages.php and services.php from bootstrap/cache

@ousid
Copy link
Contributor

ousid commented Jul 31, 2020

try to extend the Voyager User Model

// ...
class User extends \TCG\Voyager\Models\User
// ...

@ValeSauer
Copy link

Well the DatabaseUserProvider doesn't have a method getModel(). This is only available in EloquentUserProvider.php. I am using the Auth0UserProvider and have the same issue.

@MrCrayon
Copy link
Collaborator

As @ousid said User needs to extend \TCG\Voyager\Models\User for Voyager to work properly, this is usually done automatically on install but in case Voyager can't find the model you'll need to add it manually.
https://voyager-docs.devdojo.com/getting-started/installation

@ValeSauer
Copy link

Doesn't work with Auth0UserProvider, since it does not persist Users in Laravel.

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have further questions please ask in our Slack group.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants