public function getPayments()
 {
     $to = Input::get('to');
     $from = Input::get('from');
     if ($from == null || $to == null) {
         $today = LocationController::getTime();
         $todayFrom = $today['date'] . ' 00:00:00';
         $todayTo = $today['date'] . ' 23:59:59';
     } else {
         $todayFrom = $from . ' 00:00:00';
         $todayTo = $to . ' 23:59:59';
     }
     try {
         $results = Payment::where('created_at', '>', $todayFrom)->where('created_at', '<', $todayTo)->get()->toArray();
         if (!is_null($results)) {
             foreach ($results as $key => $payment) {
                 $driver = Driver::where('id', '=', $payment['driver_id'])->first()->toArray();
                 $currency = Currency::find($payment['currency'])->pluck('currency');
                 $results[$key]['driver_name'] = $driver['first'] . ' ' . $driver['last'];
                 $results[$key]['currency'] = $currency;
             }
         }
         $queries = DB::getQueryLog();
         $last_query = end($queries);
     } catch (Exception $ex) {
         \Log::error(__METHOD__ . ' | error :' . print_r($ex, 1));
     }
     //\Log::info(__METHOD__.print_r($results, 1));
     return json_encode($results);
 }
 public function showMyTrips()
 {
     $userId = Session::get('user_id');
     $to = Input::get('to');
     $from = Input::get('from');
     if ($from == null || $to == null) {
         $today = LocationController::getTime();
         $todayFrom = $today['date'] . ' 00:00:00';
         $todayTo = $today['date'] . ' 23:59:59';
     } else {
         $todayFrom = $from . ' 00:00:00';
         $todayTo = $to . ' 23:59:59';
     }
     try {
         $myTrips = DailyTrips::where('user_id', '=', $userId)->where('departure_date_time', '>', $todayFrom)->where('departure_date_time', '<', $todayTo)->orderBy('departure_date_time', 'desc')->get()->toArray();
         $carId = Session::get('car_id');
         $car = Cars::find($carId);
         if ($myTrips == null) {
             $myTrips = array('my_trips' => 'no trips have been recorded for you.');
         }
         $results = array('success' => true, 'my_trips' => $myTrips, 'car' => $car);
     } catch (Exception $ex) {
         \Log::error(__METHOD__ . ' | error :' . print_r($ex, 1));
         $results = array('success' => false, 'message' => 'an error occurred');
     }
     return $results;
 }