Home > OS >  How to call job from traits in laravel?
How to call job from traits in laravel?

Time:08-20

I want to use a job in a trait . Lumen give me following error: Call to undefined method App\Consumers\Journal::dispatch() this is my code


use App\Jobs\CreateFact;
trait Ledger
{
  
   private function save() {

 $this->dispatch(new CreateFact($entries));
}
}

Please help to resolve with issue. I am new in lumen

CodePudding user response:

You can dispatch the job in the trait using:

CreateFact::dispatch($entries);
  • Related