public function getFullUserProfile()
 {
     try {
         if (!$this->id) {
             throw new Exception('Не задан id пользователя');
         }
         $user['profile'] = $this->userTableModel->readRecordsById();
         $this->userTableModel->readUserAddress();
         $this->userTableModel->readUserPhones();
         $user['contacts'] = $this->userTableModel->getUserContacts();
         $orderModel = new OrderTableModel();
         $orderModel->setTable('order_body as b, order_type as t, order_status as s, order_delivery_type as d');
         $orderModel->setId($this->id);
         $user['orders'] = $orderModel->readRecordsById('user_id', '*', 'AND b.status_id = s.id AND b.delivery_type = d.id AND s.type_id = t.id');
         if (!empty($user['orders'])) {
             foreach ($user['orders'] as $key => $order) {
                 if ($key !== 'rowCount') {
                     $user['orders'][$key]['body'] = Basket::getProductsList($order['body']);
                 }
             }
         }
         $user['profile']['photo'] = !empty($user['profile'][0]['photo']) ? $user['profile'][0]['photo'] : \app\helpers\Path::DEFAULT_USER_AVATAR;
         $this->fullProfile = $user;
         return $user;
     } catch (Exception $ex) {
         $ex->getMessage();
     }
 }
Exemplo n.º 2
0
 public function getAllOrders($fields = '*', $condition = '')
 {
     $model = new OrderTableModel();
     $model->setTable('order_body');
     $model->readAllRecords($fields, $condition);
     $records = $model->getAllRecords();
     $userModel = new UserTableModel();
     foreach ($records as $key => $record) {
         $userModel->setId((int) $record['user_id']);
         $userModel->setTable('user');
         $records[$key]['user_name'] = $userModel->readRecordsById('id', 'username')[0]['username'];
         $records[$key]['delivery'] = $model->getDeliveryForId((int) $record['delivery_type']);
         $records[$key]['status'] = $model->getStatusForId((int) $record['status_id']);
     }
     return $records;
 }