-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Target class [app\Models\Permission] does not exist. #2274
Comments
The file content seems to be mixed up in the original post, I'll separate them: <?php
namespace App\Models;
use App\Http\Traits\AuthenticationLogable;
use Illuminate\Support\Facades\Config;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
use Illuminate\Foundation\Auth\Access\Authorizable;
use Spatie\Permission\Traits\HasRoles;
class User extends \App\Models\BaseModel implements AuthenticatableContract, AuthorizableContract, CanResetPasswordContract
{
use HasRoles, Authenticatable, Authorizable, CanResetPassword, AuthenticationLogable;
protected $table = 't_users';
etc. |
File: App\Models\Permission.php <?php
namespace App\Models;
use Spatie\Multitenancy\Models\Concerns\UsesTenantConnection;
use Spatie\Permission\Models\Permission as SpatiePermission;
class Permission extends SpatiePermission
{
use UsesTenantConnection;
public static $rules = array(
"name" => "required",
);
public static function getFieldsOpenForEdit()
{
return array("name", "display_name", "description", "created_at", "updated_at");
}
} |
File: config\permission.php <?php
return [
'models' => [
'permission' => app\Models\Permission::class, // also tried an extra \ up front
'role' => app\Models\Role::class,
],
ETC. = unchanged = |
Laravel-Permission V4 has no support, just V5 has support Please, learn to use markdown, the code is impossible to understand Maybe you forget to clean config cache |
Issue is resolved => by re-defining all interfaces and traits in the user model. |
Add the built-in middleware list, as described in the documentation
|
Hi, I'm having trouble implementing your permissions package
[Laravel-permission v.4] [PHP 7.4.15] [Laravel Framework 6.20.44].
All migrations and seeding work & 'your' databases are filled correctly, but obviously I'm doing something wrong in the binding department ... let's just say that's not my forte ... I really hope you can point me in the right direction!
When I run >
php artisan permission:show
, I get the following error message:When I try logging on into my app a similar error occurs in the log:
This might be because we already extended our User model from a base model in our application and we tried to work around that like this (3 files shown below; models\User & models\Permission & config\permission), by using interfaces and traits separately in the User model:
== File: App\Models\User.php ==
== File: App\Models\Permission.php ==
== File: config\permission.php ==
The text was updated successfully, but these errors were encountered: