4
votes

I have this error on my console. I use Jobs from Laravel 5.4 and I have move the Feed Model in App\Models\Feed. Since two days, I have this error because Laravel doesn't find the Feed Model. I have restart my Jobs with php artisan queue:restart.

[2017-07-13 10:45:33] staging.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Class 'App\Feed' not found in /home/site_com/http/www/vendor/laravel/framework/src/Illuminate/Queue/SerializesAndRestoresModelIdentifiers.php:45

<?php

namespace App\Jobs;

use App\Models\Feed;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class FetchFeeds implements ShouldQueue {
    protected $feed;
    public function __construct(Feed $feed)
    {
        $this->feed = $feed;
    }
}

My Feed model:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Jenssegers\Mongodb\Eloquent\HybridRelations;

class Feed extends Model
{
    use HybridRelations;

    protected $connection = 'mysql';

    protected $fillable = [
        //
    ];

    protected $dates = [
        'created_at',
        'updated_at'
    ];

    ...
}
2
So you have a Feed folder under Models? Please post the model as wellka_lin
I have edit the first post with the Feed model.pirmax
You likely have old jobs in the queue. Passing Eloquent models to a job gets them serialized, but because you changed the namespace of the model it can't find them anymore. Clear out the queue, or put the model back temporarily to run them.ceejayoz
I've flushed Redis database already...pirmax
Can you show us where you dispatch the job?ceejayoz

2 Answers

1
votes

I've changed the Job name, it works.

0
votes

php artisan queue:restart relies on on the cache system to schedule the restart.

If you are using APCu there is a chance that the cache it is not working with cli jobs. In this case the recommendation is to add apc.enable_cli=1 to your APCu configuration

In any case I will try to do a complete stop/start of the queue listener/worker.