jeudi 25 octobre 2018

Laravel Job running same job one after one in a loop

I am learning laravel, working on a project which runs horizon to learn about jobs. I am stuck at one place where i need to run same job few times one after one. Here is the code

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Models\Subscriptions;
class MailController extends Controller
{


    public function sendEmail() {
        Subscriptions::all()
        ->each(function($subscription) {
            SendMailJob::dispatch($subscription);
        });
    }
}

This works fine. But it runs few categories at once. Is there any way to run one job after. So basically, lets say i have 10 same jobs in default queue, but i need to run one job at a time.

Please help..



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire