protected function list_ids() { if ($this->_list_ids === NULL) { $this->_list_ids = (array) $this->_driver->all($this->_locator->xpath(), $this->_parent->id()); if ($this->_locator->filters()) { foreach ($this->_list_ids as $offset => $id) { if (!$this->_locator->is_filtered($this->_load($id), $offset)) { unset($this->_list_ids[$offset]); } } } } return $this->_list_ids; }
public function getDrivers() { $results = Driver::all()->toArray(); foreach ($results as $key => $driver) { $driverName = $driver['first'] . ' ' . $driver['last']; $email = Users::where('id', '=', $driver['user_id'])->pluck('email'); $hours = Driver::getHoursByDriverId($driver['user_id']); $trips = Driver::getTripsByDriverId($driver['user_id']); $earning = Driver::getEarningsByDriverId($driver['user_id']); $results[$key]['hours'] = $hours['hours']; $results[$key]['trips'] = $trips['count']; $results[$key]['earning'] = $earning['earning']; //.' '.$earning['currency']; $results[$key]['hour_per_trip'] = round($trips['count'] == 0 ? 0 : $hours['hours'] / $trips['count'], 2); $results[$key]['earning_per_hour'] = round($hours['hours'] == 0 ? 0 : $earning['earning'] / $hours['hours'], 2) . ' MAD'; $results[$key]['earning_per_trip'] = round($trips['count'] == 0 ? 0 : $earning['earning'] / $trips['count'], 2) . ' MAD'; $results[$key]['name'] = $driverName; $results[$key]['email'] = $email; unset($results[$key]['first']); unset($results[$key]['last']); } //Log::info(__METHOD__.print_r($results, 1)); return json_encode($results); }