php - Laravel PasswordBroker::createToken() must implement interface

I'm trying to use Laravel PasswordBroker class to createToken without sending email. But when i call createToken method, it gives me this error.

Argument 1 passed to Illuminate\Auth\Passwords\PasswordBroker::createToken() must implement interface Illuminate\Contracts\Auth\CanResetPassword, instance of stdClass given..

How can i call createToken method in my controller? As of now i'm using the code below but it gives me the error.

app('auth.password.broker')->createToken($customer);

Answer

Solution:

Your given object in this case $customer has to have an implementation of CanResetPassword which can be achieved extending Illuminate\Foundation\Auth\User on your $customer object. I strongly recommend to give it an alias if your $customer object is called User as well.

use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable {}

Hope this helps and resolves your issues.

Source