Browse Source

[Administration] Points de vente : problème possibilité de modifier le point de vente d'un autre producteur

feature/souke
Guillaume Bourgeois 10 months ago
parent
commit
c15bdde14d
1 changed files with 10 additions and 9 deletions
  1. +10
    -9
      backend/controllers/PointSaleController.php

+ 10
- 9
backend/controllers/PointSaleController.php View File

@@ -118,11 +118,7 @@ class PointSaleController extends BackendController
{
$distributionModule = $this-> getDistributionModule();
$pointSaleModule = $this->getPointSaleModule();

$model = PointSale::find()
->with('userPointSale')
->where(['id' => $id])
->one();
$model = $this->findModel($id);

foreach ($model->userPointSale as $userPointSale) {
$model->users[] = $userPointSale->id_user;
@@ -240,10 +236,15 @@ class PointSaleController extends BackendController
*/
protected function findModel(int $id)
{
if (($model = PointSale::findOne($id)) !== null) {
return $model;
} else {
throw new NotFoundHttpException('The requested page does not exist.');
$model = PointSale::find()
->with('userPointSale')
->where(['id' => $id])
->one();

if(!$model || $model->id_producer != $this->getProducerCurrent()->id) {
throw new NotFoundHttpException('Le point de vente demandé est introuvable.');
}

return $model;
}
}

Loading…
Cancel
Save