Example #1
0
 /**
  * Create and get collection of jobs from given listings
  *
  * @param  array $listings
  *
  * @return Collection
  */
 protected function getJobsCollectionFromListings(array $listings = array())
 {
     $collection = new Collection();
     array_map(function ($item) use($collection) {
         $jobs = $this->createJobArray($item);
         foreach ($jobs as $item) {
             $item = static::parseAttributeDefaults($item, $this->getDefaultResponseFields());
             $job = $this->createJobObject($item);
             $job->setQuery($this->query->getKeyword())->setSource($this->getSource());
             $collection->add($job);
         }
     }, $listings);
     return $collection;
 }
Example #2
0
 /**
  * Append a collection to this collection.
  *
  * @param Collection $collection
  *
  * @return $this
  */
 public function addCollection(Collection $collection)
 {
     // If there are jobs, add them to the collection
     if ($collection->count()) {
         foreach ($collection->all() as $job) {
             $this->add($job);
         }
     }
     // If there are errors, add them to the collection
     if ($collection->getErrors()) {
         foreach ($collection->getErrors() as $error) {
             $this->addError($error);
         }
     }
     return $this;
 }