inRandomOrder()->get(); } public static function getAllProperties() { // get all properties from model in random order. return Property::select('id','property_platform_id')->inRandomOrder()->get(); } public static function dispatchPropertyJobs() { $seeds = self::getAllSeeds(); foreach($seeds as $seed){ ScrapeProperty::dispatch($seed->uri); } } public static function dispatchPropertyDataJobs() { $properties = self::getAllProperties(); foreach($properties as $property){ dump($property->property_platform_id); // ScrapePropertyData::dispatch($property->property_platform_id); } } public static function scrapeProperty($uri) { //$response = Http::get($seed->uri); $response = Http::get('https://diani.xyz/test_2.json'); $json = $response->json(); foreach($json['offers'] as $offer){ $property = Property::firstWhere('property_platform_id', $offer['id']); $geoLocation = implode(',', $offer['geoLocation']); if($property){ $property->last_found = now(); $property->save(); if($property->check_data !== $geoLocation){ Exception::create([ 'exception' => 'geoLocation was different: '.$geoLocation, 'entity_type' => 'property', 'entity_id' => $offer['id'] ]); } }else{ Property::create([ 'property_platform_id' => $offer['id'], 'seed_id' => $seed->id, 'check_data' => $geoLocation, 'last_found' => now() ]); } } } public static function scrapeOccupancy($propertyId){ /* $calendar = Http::get('https://www.e-domizil.ch/api/v2/calendar/'.$propertyId, [ 'year' => date("Y"), 'month' => date("m") ]); $data_cal = $calendar->json(); $price = Http::get('https://www.e-domizil.ch/booking/checkout/priceDetails/'.$propertyId); $data_price = $price->json(); $offer = Http::get('https://www.e-domizil.ch/rental/offer/'.$propertyId); $data_offer = $offer->json(); */ /* $data = $response->json(); Occupancy::create([ 'property_id' => $property->id, 'occupancy' => json_encode($data['content']['days']), 'header' => json_encode($response->headers()) ]); */ } }