|
|
|
|
|
|
|
|
{ |
|
|
{ |
|
|
$model = $this->findModel($id); |
|
|
$model = $this->findModel($id); |
|
|
|
|
|
|
|
|
$class = $this->getClass(); |
|
|
|
|
|
$model = $class::searchOne([ |
|
|
|
|
|
'id' => $id |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
if(!$model) { |
|
|
if(!$model) { |
|
|
throw new NotFoundHttpException('Le document n\'a pas été trouvé.'); |
|
|
throw new NotFoundHttpException('Le document n\'a pas été trouvé.'); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
if ($user) { |
|
|
if ($user) { |
|
|
|
|
|
|
|
|
|
|
|
$document = null ; |
|
|
|
|
|
if(Document::isValidClass($classDocument)) { |
|
|
|
|
|
$document = $classDocument::searchOne([ |
|
|
|
|
|
'id' => $idDocument, |
|
|
|
|
|
'id_user' => $idUser |
|
|
|
|
|
]) ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if($document && $document->id_user == $user->id) { |
|
|
|
|
|
$address = $document->address ; |
|
|
|
|
|
} |
|
|
|
|
|
else { |
|
|
|
|
|
$address = $user->getFullAddress() ; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$json = [ |
|
|
$json = [ |
|
|
'return' => 'success', |
|
|
'return' => 'success', |
|
|
'address' => $user->getFullAddress() |
|
|
|
|
|
|
|
|
'address' => $address |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
if($classDocument == 'Invoice') { |
|
|
if($classDocument == 'Invoice') { |