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 Illuminate\Database\Query\Builder::check() #316

Closed
mike23v opened this issue Sep 25, 2017 · 4 comments
Closed

Call to undefined method Illuminate\Database\Query\Builder::check() #316

mike23v opened this issue Sep 25, 2017 · 4 comments
Labels
help wanted Assistance or contributions needed

Comments

@mike23v
Copy link

mike23v commented Sep 25, 2017

Q A
Bug? not sure
New Feature? no
Framework Laravel
Framework version 5.4.36
Package version 4.0
PHP version 7.0.13

Actual Behaviour

I'm having the following error
"Call to undefined method Illuminate\Database\Query\Builder::check()"
when using the said package.

This is what I've tried so far in my model:

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Notifications\Notifiable;

use OwenIt\Auditing\Contracts\Auditable as AuditableContract;
use OwenIt\Auditing\Auditable;
use OwenIt\Auditing\Contracts\UserResolver;

class Library extends Model implements AuditableContract, UserResolver
{
    use Notifiable;

    use Auditable;

    protected $fillable = ['email'];

    protected $table = 'libraries';

    public static function resolveId()
    {
        return User::check() ? User::user()->getAuthIdentifier() : null;
    }
}
@quetzyg
Copy link
Contributor

quetzyg commented Sep 25, 2017

Hi @mike23v,

As you can see in the Resolver part of the documentation, the resolver uses Auth, like so:

return Auth::check() ? Auth::user()->getAuthIdentifier() : null;

When in doubt, always check the docs. 😉

@quetzyg quetzyg closed this as completed Sep 25, 2017
@quetzyg quetzyg added the help wanted Assistance or contributions needed label Sep 25, 2017
@mike23v
Copy link
Author

mike23v commented Sep 26, 2017

Hi @quetzyg ,

It something to do in the config/audit.php

'user' => [
'primary_key' => 'id',
'foreign_key' => 'user_id',
'model' => App\User::class,
'resolver' => App\User::class,
],

When I try to change the 'resolver' to

   'resolver'    => function () {
        return Auth::check() ? Auth::user()->getAuthIdentifier() : null;
    },

it works fine. I believed you made some fix about this. It will work out if you return it to callable than using the FQCN. Thanks

@quetzyg
Copy link
Contributor

quetzyg commented Sep 26, 2017

Please, read the documentation. It's all there.

@mike23v
Copy link
Author

mike23v commented Sep 27, 2017

@quetzyg , Thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Assistance or contributions needed
Projects
None yet
Development

No branches or pull requests

2 participants