mostafamaklad / laravel-permission-mongodb

Associate users with roles and permissions using Laravel and MongoDB
https://maklad.dev
MIT License
112 stars 66 forks source link

Installation Error #64

Closed Giacomo92 closed 6 years ago

Giacomo92 commented 6 years ago

When I try to install I get this error:

In PermissionRegistrar.php line 36: Type error: Argument 1 passed to Maklad\Permission\PermissionRegistrar::Mak lad\Permission{closure}() must be an instance of Maklad\Permission\Models\ Permission, instance of Spatie\Permission\Models\Permission given

This is my user model:

namespace App\Models\Auth\User;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;

use Jenssegers\Mongodb\Eloquent\SoftDeletes;

class User extends MDModel{   
   protected $connection = 'mongodb';

   protected $table = 'users';

   use SoftDeletes;

   protected $dates = ['deleted_at', 'created_at', 'updated_at'];

}

I have also created the users collection on the DB

How can I fix this?

mostafamaklad commented 6 years ago

Hello ,

First you model must extends from Jenssegers\Mongodb\Eloquent\Model Second you have to use HasRoles Trait Third, use Maklad\Permission\Models Permission instead of Spatie\Permission\Models\Permission in config/permission.php

namespace App\Models\Auth\User;

use Jenssegers\Mongodb\Eloquent\Model as Eloquent;
use Jenssegers\Mongodb\Eloquent\SoftDeletes;
use Maklad\Permission\Traits\HasRoles;

class User extends Eloquent{   
   protected $connection = 'mongodb';

   protected $table = 'users';

   use SoftDeletes;
   use HasRoles;

   protected $dates = ['deleted_at', 'created_at', 'updated_at'];

}
Giacomo92 commented 6 years ago

My problem was due to the preesistent version of Laravel Permission by Spatie conflict with the new installation. After I cleaned my project all it is working. Thank you @mostafamaklad

mostafamaklad commented 6 years ago

You are welcome @Giacomo92