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

Call to undefined method App\Models\User::isSuper() #48

Closed
hhhc opened this issue Feb 24, 2022 · 1 comment
Closed

Call to undefined method App\Models\User::isSuper() #48

hhhc opened this issue Feb 24, 2022 · 1 comment

Comments

@hhhc
Copy link

hhhc commented Feb 24, 2022

Hi,

I have just tried to install your redirect plugin in a site where I had to move users to a separate sqlite, following https://statamic.dev/tips/storing-users-in-a-database

After installation of the redirect plugin I am facing a
BadMethodCallException
Call to undefined method App\Models\User::isSuper()

issue.

The User Class is

<?php

namespace App\Models;

use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
    use HasFactory, 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',
    ];
}

as per description. Can you please help?

@riasvdv
Copy link
Owner

riasvdv commented Feb 24, 2022

I'll look into fixing it this week, as a note to myself I probably need to use \Statamic\Facades\User::fromUser($user)->isSuper() instead of just auth()->user()

You can temporarily fix this in your application by adding a isSuper() method to your user model that looks like this:

public function isSuper()
{
    return \Statamic\Facades\User::fromUser($this)->isSuper();
}

Let me know if that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants