Browse Source

User : ajout fonction getFullAddress()

refactoring
Guillaume Bourgeois 4 years ago
parent
commit
7c46297cb4
2 changed files with 13 additions and 5 deletions
  1. +4
    -5
      backend/controllers/DocumentController.php
  2. +9
    -0
      common/models/User.php

+ 4
- 5
backend/controllers/DocumentController.php View File

@@ -151,15 +151,14 @@ class DocumentController extends BackendController
\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

if ($idUser > 0) {
$user = User::findOne($idUser);
$user = User::searchOne([
'id' => $idUser
]) ;

if ($user) {
$address = $user['lastname'] . ' ' . $user['name'] . "\n";
$address .= $user['address'];

return [
'return' => 'success',
'address' => $address
'address' => $user->getFullAddress()
];
}
}

+ 9
- 0
common/models/User.php View File

@@ -651,6 +651,14 @@ class User extends ActiveRecordCommon implements IdentityInterface
->send();
}
}

public function getFullAddress()
{
$address = '' ;
$address .= $this->lastname . ' ' . $this->name . "\n";
$address .= $this->address;
return $address ;
}
/**
* Retourne l'ID de l'utilisateur courant connecté.
@@ -684,4 +692,5 @@ class User extends ActiveRecordCommon implements IdentityInterface
return User::getCurrentStatus() == USER::STATUS_ADMIN || User::getCurrentStatus() == USER::STATUS_PRODUCER;
}


}

Loading…
Cancel
Save