Example #1
0
 /**
  * Execute the job.
  */
 public function handle()
 {
     $api = new ItemAPI();
     $item = Item::findOrNew($this->id);
     // Item didn't exist yet, so set the model id
     if (!$item->exists) {
         $item->id = $this->id;
     }
     // Let's grab some details from the API
     $details['en'] = $api->getDetails($this->id, 'en');
     $details['de'] = $api->getDetails($this->id, 'de');
     $details['fr'] = $api->getDetails($this->id, 'fr');
     $details['es'] = $api->getDetails($this->id, 'es');
     // Save the details in the model after some transformation
     $item = $this->processDetails($item, $details);
     // Fire off post processing events
     $response = Event::fire(new ItemDetailsUpdated($item));
     // Save the item after post processing
     $item = array_pop($response);
     $item->save();
 }