. */ namespace App\Jobs; use App\Contracts\Searchable; use App\Jobs\Job; use DB; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Database\Eloquent\Model; use Illuminate\Queue\InteractsWithQueue; use SerializesModels; class UpdateSearchIndexForEntity extends Job implements ShouldQueue { use InteractsWithQueue, SerializesModels; protected $entity; /** * Create a new job instance. * * @param Model $entity */ public function __construct(Searchable $entity) { $this->entity = $entity; } /** * Execute the job. * * @return void */ public function handle() { $this->beforeHandle(); $this->entity->updateElasticsearchEntrySynchronously(); } }