public function recruitPastNumbers($mls_id) { $numbers = []; $numbers['listings_taken'] = RecruitListing::whereBetween('OriginalEntryTimestamp', [$this->pastStart, $this->pastEnd])->where('ListAgentMLSID', $mls_id)->get(); $numbers['listings_sold'] = RecruitListing::whereBetween('CloseDate', [$this->pastStart, $this->pastEnd])->where('ListAgentMLSID', $mls_id)->where('Status', 'Sold')->get(); $numbers['buyer_sides'] = RecruitListing::whereBetween('CloseDate', [$this->pastStart, $this->pastEnd])->where('SellingAgentMLSID', $mls_id)->get(); return $numbers; }
public function runAgentListings($agent_id, $status, $start = '') { if ($start == '') { $start_range = Carbon::now()->subYears(4)->format('Y-m-d\\TH:i:s'); } else { $start_range = $start; } $end_range = Carbon::now()->format('Y-m-d\\TH:i:s'); if ($this->connect() == true) { // $since = Carbon::now()->subDays($daysBack)->format('Y-m-d\TH:i:s'); if ($status == 'listing') { $search = $this->rets->SearchQuery('Property', 'Listing', "(ListAgentMLSID = {$agent_id}),(OriginalEntryTimestamp = {$start_range}-{$end_range})"); } else { $search = $this->rets->SearchQuery('Property', 'Listing', "(SellingAgentMLSID = {$agent_id}),(CloseDate = {$start_range}-{$end_range})"); } $listings = []; while ($listing = $this->rets->FetchRow($search)) { $args = ['id' => $listing['MLSNumber'], 'OriginalEntryTimestamp' => $listing['OriginalEntryTimestamp'], 'PendingDate' => $listing['PendingDate'], 'CloseDate' => $listing['CloseDate'], 'ClosePrice' => $listing['ClosePrice'], 'ListAgentMLSID' => $listing['ListAgentMLSID'], 'SellingAgentMLSID' => $listing['SellingAgentMLSID'], 'ListPrice' => $listing['ListPrice'], 'CDOM' => $listing['CDOM'], 'StreetName' => $listing['StreetName'], 'StreetNumber' => $listing['StreetNumber'], 'City' => $listing['City'], 'ZipCode' => $listing['ZipCode'], 'Status' => $listing['Status'], 'PropertySubType' => $listing['PropertySubType']]; RecruitListing::updateOrCreate(['id' => $listing['MLSNumber']], $args); } return $listings; } else { return false; } }