/**
  * Retrieve all SMSs that were sent to a selected recipient. 
  * Select recipient by ID.
  * @param int|string $recipientId
  * @param boolean $unseen Optional. If you want to retrieve only unseen SMSs.
  * @return array(SMS)
  */
 public function get_all_recipient_SMSs($recipientId, $unseen = false)
 {
     $SMS = new ModelTemplate('SMS');
     $SMSs = null;
     if ($unseen) {
         $SMSs = $SMS->get_all(array('recipient_id', 'is_seen', 'is_resolved'), array($recipientId, 'false', 'false'));
     } else {
         $SMSs = $SMS->get_all(array('recipient_id', 'is_resolved'), array($recipientId, 'false'));
     }
     if ($SMSs) {
         $truckDriverCtr = new TruckDriver_Controller();
         $logisticianCtr = new Logistician_Controller();
         // Retrieve SMSs' senders and recipients.
         foreach ($SMSs as $key => &$SMS) {
             if ($sender = $truckDriverCtr->get_truck_driver_by_id($SMS->sender_id)) {
                 $SMS->sender_id = $sender;
             }
             if ($recipient = $logisticianCtr->get_logistician_by_id($SMS->recipient_id)) {
                 $SMS->recipient_id = $recipient;
             }
             // If no sender and recipient delete SMS.
             if (!($sender && $recipient)) {
                 unset($SMSs[$key]);
             }
         }
     }
     return $SMSs;
 }
 /**
  * Process the following URIs:
  * api/v1/truck_driver/ - to get all truck drivers.
  * api/v1/truck_driver/count/ - to get the total number of all drivers.
  * api/v1/truck_driver/{id}/ - to get a driver by ID.
  * api/v1/truck_driver/{id}/truck/ - to get a truck driver's truck.
  * @return TruckDriver|Truck
  */
 private function process_truck_driver_get()
 {
     $truckDriverCtr = new TruckDriver_Controller();
     // URI: api/v1/truck_driver/
     if (empty($this->arguments) && $this->verb === '') {
         // Return truck drivers, if there are any, otherwise - null.
         if ($truckDrivers = $truckDriverCtr->get_all_truck_drivers()) {
             foreach ($truckDrivers as &$td) {
                 $td = $td->get_all_fields();
             }
             return $truckDrivers;
         }
     } else {
         // URI: api/v1/truck_driver/{action}/
         if ($this->verb !== '') {
             // URI: api/v1/truck_driver/count/
             if ($this->verb === 'count') {
                 return $truckDriverCtr->count_truck_drivers();
             }
         } elseif (count($this->arguments) === 1) {
             // Return a truck driver, if there is such, otherwise - null.
             if ($truckDriver = $truckDriverCtr->get_truck_driver_by_id($this->arguments[0])) {
                 return $truckDriver->get_all_fields();
             }
         } elseif (count($this->arguments) === 2 && $this->arguments[1] === 'truck') {
             $tctr = new Truck_Controller();
             // Return a truck driver's truck, if they have such, otherwise - null.
             if ($truck = $tctr->get_truck_driver_truck($this->arguments[0])) {
                 return $truck->get_all_fields();
             }
         }
     }
     return null;
 }