Hi. Show us where $user comes from. It looks like it's a query builder instance instead of the User model.
Mar 27, 2020
5
Level 3
Call to undefined method - laravel impersonate
goodday,
I setting up an package: laravel impersonate.
https://github.com/404labfr/laravel-impersonate
After installing it give the following error if when i use the the following:
what i did:
composer require lab404/laravel-impersonate
Add the service provider at the end of your config/app.php:
'providers' => [
// ...
Lab404\Impersonate\ImpersonateServiceProvider::class,
],
Add the trait Lab404\Impersonate\Models\Impersonate to your User model.
placed: Route::impersonate();
run: php artisan vendor:publish --tag=impersonate
By running the following i get the error's
@canBeImpersonated($user)
<a href="{{ route('impersonate', $user->id) }}">Impersonate this user</a>
@endCanBeImpersonated
error:
Call to undefined method Illuminate\Database\Query\Builder::canBeImpersonated() (View: /Users/mbolivier/Applications/ligplaats/resources/views/my-account/users/index_admin.blade.php)
any help would be appreciated.
thanks
Level 14
Whoops. According the docs you have to add that method to the User model. See the README.
/**
* @return bool
*/
public function canBeImpersonated()
{
// For example
return $this->can_be_impersonated == 1;
}
Please or to participate in this conversation.