Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ioiofadhil's avatar

No query results for model INSIDE JOB

Hi, i want make a simple task for queue laravel. I have this error in "failed_jobs" Illuminate\Database\Eloquent\ModelNotFoundException: No query results for model....... What did i do wrong?

//controller
    public function addUser(Request $req)
    {
        $user = new User;
        $user->name = $req->name;
        $user->username = $req->username;
        $user->email = $req->email;
        $user->password = bcrypt($req->password);
        dispatch(new adduser($user));
        // adduser::dispatch();
        return 'added';
    }
//Job
class adduser implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    public $user;
    public function __construct($user)
    {
        $this->user = new User;
        $this->user = $user;
    }
    public function handle()
    {
        $this->user->save();
    }
}
0 likes
3 replies
Sinnbeck's avatar

Why are you trying to create a single user on a queue? It is a simple task that you can easily do directly in the controller. Queues are for time consuming tasks. Dispatching the job, probably takes the same time as saving the user

ioiofadhil's avatar

@Sinnbeck yeah i know. i just wanna know how it works, im new to it... i ended up remove the SerializesModels and it worked.

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@ioiofadhil yeah. You could make it work by saving first, giving the user an ID. Then the job can find the user by that ID :)

Please or to participate in this conversation.