Browse Source

Adapter le système de produits du backend pour gérer le multi-boulangerie

prodstable
keun 8 years ago
parent
commit
8ab5d46b86
3 changed files with 13 additions and 2 deletions
  1. +4
    -1
      backend/controllers/ProduitController.php
  2. +9
    -1
      common/models/Produit.php
  3. BIN
      frontend/web/uploads/pain-complet-aux-graines-de-tournesol-580099da7d0c8.jpg

+ 4
- 1
backend/controllers/ProduitController.php View File

public function actionIndex() public function actionIndex()
{ {
$dataProvider = new ActiveDataProvider([ $dataProvider = new ActiveDataProvider([
'query' => Produit::find()->where('(vrac IS NULL OR vrac = 0)')->orderBy('order ASC'),
'query' => Produit::find()
->where('(vrac IS NULL OR vrac = 0)')
->andWhere(['id_boulangerie'=>Yii::$app->user->identity->id])
->orderBy('order ASC'),
'pagination' => [ 'pagination' => [
'pageSize' => 1000, 'pageSize' => 1000,
], ],

+ 9
- 1
common/models/Produit.php View File

[['prix', 'poids'], 'number'], [['prix', 'poids'], 'number'],
[['illustration','photo'], 'file'], [['illustration','photo'], 'file'],
[['nom', 'description', 'illustration', 'photo', 'saison','diminutif'], 'string', 'max' => 255], [['nom', 'description', 'illustration', 'photo', 'saison','diminutif'], 'string', 'max' => 255],
[['recette'], 'string','max'=>1000]
[['recette'], 'string','max'=>1000],
['id_boulangerie','integer'],
['id_boulangerie','required'],
]; ];
} }


else else
return $this->description ; return $this->description ;
} }
public function save($runValidation = true, $attributeNames = NULL)
{
$this->id_boulangerie = Yii::$app->user->identity->id ;
return parent::save($runValidation, $attributeNames) ;
}
} }

BIN
frontend/web/uploads/pain-complet-aux-graines-de-tournesol-580099da7d0c8.jpg View File

Before After
Width: 1600  |  Height: 1164  |  Size: 482KB

Loading…
Cancel
Save