/**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $properties = \App\Property::with('propertyImages')->get();
     foreach ($properties as $checkProperty) {
         try {
             $results = \App\Libraries\RetsQuery::properties('Property', 'Listing', '(Matrix_Unique_ID = ' . $checkProperty['Matrix_Unique_ID'] . ')');
         } catch (Exception $e) {
             Bugsnag::notifyException($e);
         } catch (PHRETS\Exceptions\CapabilityUnavailable $e) {
             Bugsnag::notifyException($e);
         }
         foreach ($results as $property) {
             if ($property['Status'] !== 'Active') {
                 if (!empty($checkProperty->propertyImages->toArray())) {
                     $this->removeClosedImages($checkProperty->propertyImages);
                 }
                 $this->removeFromElasticSearch($property['MLSNumber']);
                 $property = \App\Property::find($checkProperty['id']);
                 if ($property) {
                     $property->delete();
                 }
             }
         }
     }
     dispatch((new \App\Jobs\RemoveUnrelatedImages())->onQueue('images'));
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $days = 100;
     $time = date('H:i:s');
     $startDate = date('Y-m-d', strtotime('-40 days'));
     $date = date('Y-m-d', strtotime('-0days'));
     while ($startDate <= $date) {
         try {
             $results = \App\Libraries\RetsQuery::properties('Property', 'Listing', '(Area=101,102,103,201,202,203,204,301,302,303,401,402,403,404,405,501,502,503,504,505,601,602,603,604,605,606) AND (ListPrice=100000+) AND (PropertyType=RES) AND NOT (PropertySubType=CON) AND (Status=A) AND (OriginalEntryTimestamp=' . $startDate . 'T' . $time . '-' . date('Y-m-d', strtotime('-' . $days . 'days')) . ')');
         } catch (Exception $e) {
             Bugsnag::notifyException($e);
         } catch (PHRETS\Exceptions\CapabilityUnavailable $e) {
             Bugsnag::notifyException($e);
         }
         $days = $days - 20;
         $startDate = date('Y-m-d', strtotime("+20 days", strtotime($startDate)));
         $results = $this->appendDescription($results->toArray());
         foreach ($results as $property) {
             dispatch((new MakeProperty($property))->onQueue('createProperty'));
         }
     }
 }