@@ -68,31 +68,31 @@ class AccessoryController extends BackendController | |||
public function actionIndex() | |||
{ | |||
$accessoryModule = $this->getAccessoryModule(); | |||
return $this->render('index', [ | |||
'searchModel' => $accessoryModule->getBuilder()->instanciateAccessory($this->getProducerCurrent()), | |||
'dataProvider' => $accessoryModule->getRepository()->queryAll()->getDataProvider(20), | |||
'dataProvider' => $this->getAccessoryModule()->getRepository() | |||
->queryAccessories()->getDataProvider(20), | |||
]); | |||
} | |||
public function actionCreate() | |||
{ | |||
$accessoryModule = $this->getAccessoryModule(); | |||
$accessory = $accessoryModule->getBuilder()->instanciateAccessory($this->getProducerCurrent()); | |||
$accessoryModel = $accessoryModule->getBuilder()->instanciateAccessory($this->getProducerCurrent()); | |||
if ($accessory->load(\Yii::$app->request->post()) && $accessory->validate()) { | |||
if ($accessoryModel->load(\Yii::$app->request->post()) && $accessoryModel->validate()) { | |||
$accessory = $accessoryModule->getManager()->createAccessory( | |||
$this->getProducerCurrent(), | |||
$accessory->getName(), | |||
$accessory->getQuantity() | |||
$accessoryModel->getName(), | |||
$accessoryModel->getQuantity() | |||
); | |||
$this->afterSave($accessory, $accessoryModel->getSelectedProductsIds()); | |||
$this->setFlash('success', "Accessoire ajouté"); | |||
return $this->redirectAfterSave('accessory', $accessory->getId()); | |||
} | |||
return $this->render('create', [ | |||
'accessory' => $accessory, | |||
'accessory' => $this->initFormModel($accessoryModel), | |||
'productsArray' => $this->findProducts() | |||
]); | |||
} | |||
@@ -104,12 +104,13 @@ class AccessoryController extends BackendController | |||
$accessory = $this->findAccessory($id); | |||
if ($accessory->load(\Yii::$app->request->post()) && $accessory->validate() && $accessory->save()) { | |||
$this->setFlash('success', "Accessoire modifié"); | |||
$this->afterSave($accessory, $accessory->getSelectedProductsIds()); | |||
return $this->redirectAfterSave('accessory', $accessory->getId()); | |||
} | |||
return $this->render('update', [ | |||
'accessory' => $accessory, | |||
'accessory' => $this->initFormModel($accessory), | |||
'productsArray' => $this->findProducts() | |||
]); | |||
} | |||
@@ -128,6 +129,19 @@ class AccessoryController extends BackendController | |||
return $this->redirect('index'); | |||
} | |||
public function afterSave(Accessory $accessory, $selectedProductsIdsArray): void | |||
{ | |||
if(!is_array($selectedProductsIdsArray)) { | |||
$selectedProductsIdsArray = []; | |||
} | |||
$this->getAccessoryModule()->getManager()->manageProducts($accessory, $selectedProductsIdsArray); | |||
} | |||
public function findProducts(): array | |||
{ | |||
return $this->getProductModule()->getRepository()->findProducts(true); | |||
} | |||
/** | |||
* @throws NotFoundHttpException | |||
*/ | |||
@@ -139,4 +153,10 @@ class AccessoryController extends BackendController | |||
throw new NotFoundHttpException("L'accessoire n'a pas été trouvé."); | |||
} | |||
} | |||
public function initFormModel(Accessory $accessoryModel) | |||
{ | |||
$this->getAccessoryModule()->getBuilder()->initSelectedProductsIds($accessoryModel); | |||
return $accessoryModel; | |||
} | |||
} |
@@ -36,6 +36,8 @@ | |||
* termes. | |||
*/ | |||
use yii\helpers\ArrayHelper; | |||
use yii\helpers\Html; | |||
use yii\widgets\ActiveForm; | |||
?> | |||
@@ -55,6 +57,19 @@ use yii\widgets\ActiveForm; | |||
<?= $form->field($accessory, 'quantity')->textInput() ?> | |||
</div> | |||
</div> | |||
<div class="panel panel-default" id="panel-products"> | |||
<div class="panel-heading"> | |||
<h3 class="panel-title"> | |||
<i class="fa fa-clone"></i> | |||
Produits | |||
</h3> | |||
</div> | |||
<div class="panel-body"> | |||
<?= Html::activeCheckboxList($accessory, 'selected_products_ids', ArrayHelper::map($productsArray, 'id', function ($product, $defaultValue) { | |||
return Html::encode($product->name); | |||
}), ['encode' => false, 'class' => '']) ?> | |||
</div> | |||
</div> | |||
</div> | |||
<?= $this->render('@backend/views/_include/form_actions.php',[ | |||
'model' => $accessory, |
@@ -45,5 +45,6 @@ $this->addBreadcrumb('Ajouter') ; | |||
<div class="accessory-create"> | |||
<?= $this->render('_form', [ | |||
'accessory' => $accessory, | |||
'productsArray' => $productsArray | |||
]) ?> | |||
</div> |
@@ -52,10 +52,22 @@ $this->addButton(['label' => 'Nouvel accessoire <span class="glyphicon glyphicon | |||
<div class="accessory-index"> | |||
<?= GridView::widget([ | |||
'filterModel' => $searchModel, | |||
'dataProvider' => $dataProvider, | |||
'columns' => [ | |||
'name', | |||
'quantity', | |||
[ | |||
'label' => 'Produits', | |||
'format' => 'raw', | |||
'value' => function($accessory) { | |||
$html = ''; | |||
foreach($accessory->getProductAccessories() as $productAccessory) { | |||
$html .= '<span class="label label-default">'.Html::encode($productAccessory->getProduct()->name).'</span> '; | |||
} | |||
return $html; | |||
} | |||
], | |||
[ | |||
'class' => 'yii\grid\ActionColumn', | |||
'template' => '{update} {delete}', |
@@ -48,5 +48,6 @@ $this->addBreadcrumb('Modifier') ; | |||
<div class="accessory-update"> | |||
<?= $this->render('_form', [ | |||
'accessory' => $accessory, | |||
'productsArray' => $productsArray | |||
]) ?> | |||
</div> |
@@ -236,7 +236,6 @@ $taxRateModule = $this->getTaxRateModule(); | |||
</div> | |||
</div> | |||
</div> | |||
</div> | |||
<div class="clr"></div> | |||
</div> | |||
@@ -248,5 +247,4 @@ $taxRateModule = $this->getTaxRateModule(); | |||
]); ?> | |||
<?php ActiveForm::end(); ?> | |||
</div> |
@@ -2308,6 +2308,12 @@ body.login-page .login-box .login-box-body .checkbox label input { | |||
font-weight: normal; | |||
} | |||
/* line 5, ../sass/accessory/_form.scss */ | |||
.accessory-form #panel-products .panel-body label { | |||
display: block; | |||
font-weight: normal; | |||
} | |||
/** | |||
Copyright Souke (2018) | |||
@@ -0,0 +1,11 @@ | |||
.accessory-form { | |||
#panel-products { | |||
.panel-body { | |||
label { | |||
display: block; | |||
font-weight: normal; | |||
} | |||
} | |||
} | |||
} |
@@ -1533,6 +1533,7 @@ a.btn, button.btn { | |||
@import "subscription/_form.scss" ; | |||
@import "product/_index.scss" ; | |||
@import "product/_form.scss" ; | |||
@import "accessory/_form.scss" ; | |||
@import "stats/_products.scss" ; | |||
@import "distribution/_index.scss" ; | |||
@import "user/_emails.scss" ; |
@@ -28,6 +28,7 @@ class BusinessLogic | |||
$this->getUserModule(), | |||
$this->getUserMessageModule(), | |||
$this->getPointSaleDistributionModule(), | |||
$this->getProductAccessoryModule(), | |||
$this->getAccessoryModule(), | |||
$this->getProductDistributionModule(), | |||
$this->getProductCategoryModule(), |
@@ -26,6 +26,7 @@ use domain\Producer\Producer\ProducerModule; | |||
use domain\Producer\ProducerPriceRange\ProducerPriceRangeModule; | |||
use domain\Product\Accessory\AccessoryModule; | |||
use domain\Product\Product\ProductModule; | |||
use domain\Product\ProductAccessory\ProductAccessoryModule; | |||
use domain\Product\ProductCategory\ProductCategoryModule; | |||
use domain\Product\ProductPointSale\ProductPointSaleModule; | |||
use domain\Product\ProductPrice\Module\ProductPriceModule; | |||
@@ -43,6 +44,11 @@ use domain\User\UserUserGroup\UserUserGroupModule; | |||
trait BusinessLogicTrait | |||
{ | |||
public function getProductAccessoryModule(): ProductAccessoryModule | |||
{ | |||
return ProductAccessoryModule::getInstance(); | |||
} | |||
public function getAccessoryModule(): AccessoryModule | |||
{ | |||
return AccessoryModule::getInstance(); |
@@ -0,0 +1,31 @@ | |||
<?php | |||
use yii\db\Migration; | |||
use yii\db\Schema; | |||
/** | |||
* Class m240620_074924_create_table_product_accessory | |||
*/ | |||
class m240620_074924_create_table_product_accessory extends Migration | |||
{ | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function safeUp() | |||
{ | |||
$this->createTable('product_accessory', [ | |||
'id' => 'pk', | |||
'id_product' => Schema::TYPE_INTEGER.' NOT NULl', | |||
'id_accessory' => Schema::TYPE_INTEGER.' NOT NULl', | |||
'quantity' => Schema::TYPE_INTEGER.' NOT NULL' | |||
]); | |||
} | |||
/** | |||
* {@inheritdoc} | |||
*/ | |||
public function safeDown() | |||
{ | |||
$this->dropTable('product_accessory'); | |||
} | |||
} |
@@ -4,10 +4,14 @@ namespace domain\Product\Accessory; | |||
use common\components\ActiveRecordCommon; | |||
use domain\Producer\Producer\Producer; | |||
use domain\Product\ProductAccessory\ProductAccessory; | |||
use yii\db\ActiveQuery; | |||
class Accessory extends ActiveRecordCommon | |||
{ | |||
// Produits sélectionnés dans le formulaire d'édition | |||
public $selected_products_ids; | |||
public static function tableName() | |||
{ | |||
return 'accessory'; | |||
@@ -19,6 +23,7 @@ class Accessory extends ActiveRecordCommon | |||
[['name', 'id_producer'], 'required'], | |||
[['name'], 'string', 'max' => 255], | |||
[['quantity', 'id_producer'], 'integer'], | |||
[['selected_products_ids'], 'safe'], | |||
]; | |||
} | |||
@@ -71,10 +76,31 @@ class Accessory extends ActiveRecordCommon | |||
return $this; | |||
} | |||
public function getProductAccessories(): array | |||
{ | |||
return $this->productAccessoriesRelation; | |||
} | |||
public function getSelectedProductsIds() | |||
{ | |||
return $this->selected_products_ids; | |||
} | |||
public function setSelectedProductsIds(array $selectedProductsIdsArray): self | |||
{ | |||
$this->selected_products_ids = $selectedProductsIdsArray; | |||
return $this; | |||
} | |||
/* Relations */ | |||
public function getProducerRelation(): ActiveQuery | |||
{ | |||
return $this->hasOne(Producer::class, ['id' => 'id_producer']); | |||
} | |||
public function getProductAccessoriesRelation(): ActiveQuery | |||
{ | |||
return $this->hasMany(ProductAccessory::class, ['id_accessory' => 'id']); | |||
} | |||
} |
@@ -4,9 +4,17 @@ namespace domain\Product\Accessory; | |||
use domain\_\AbstractBuilder; | |||
use domain\Producer\Producer\Producer; | |||
use domain\Product\ProductAccessory\ProductAccessoryRepository; | |||
class AccessoryBuilder extends AbstractBuilder | |||
{ | |||
protected ProductAccessoryRepository $productAccessoryRepository; | |||
public function loadDependencies(): void | |||
{ | |||
$this->productAccessoryRepository = $this->loadService(ProductAccessoryRepository::class); | |||
} | |||
public function instanciateAccessory(Producer $producer): Accessory | |||
{ | |||
$accessory = new Accessory(); | |||
@@ -14,4 +22,14 @@ class AccessoryBuilder extends AbstractBuilder | |||
return $accessory; | |||
} | |||
public function initSelectedProductsIds(Accessory $accessory): void | |||
{ | |||
$selectedProductsIdsArray = []; | |||
$productAccessoriesArray = $this->productAccessoryRepository->findProductAccessoriesByAccessory($accessory); | |||
foreach($productAccessoriesArray as $productAccessory) { | |||
$selectedProductsIdsArray[] = $productAccessory->getProduct()->id; | |||
} | |||
$accessory->setSelectedProductsIds($selectedProductsIdsArray); | |||
} | |||
} |
@@ -4,14 +4,22 @@ namespace domain\Product\Accessory; | |||
use domain\_\AbstractManager; | |||
use domain\Producer\Producer\Producer; | |||
use domain\Product\Product\ProductRepository; | |||
use domain\Product\ProductAccessory\ProductAccessoryManager; | |||
use domain\Product\ProductAccessory\ProductAccessoryRepository; | |||
use yii\base\ErrorException; | |||
class AccessoryManager extends AbstractManager | |||
{ | |||
protected AccessoryBuilder $accessoryBuilder; | |||
protected ProductAccessoryManager $productAccessoryManager; | |||
protected ProductRepository $productRepository; | |||
public function loadDependencies(): void | |||
{ | |||
$this->accessoryBuilder = $this->loadService(AccessoryBuilder::class); | |||
$this->productAccessoryManager = $this->loadService(ProductAccessoryManager::class); | |||
$this->productRepository = $this->loadService(ProductRepository::class); | |||
} | |||
public function createAccessory(Producer $producer, string $name, ?int $quantity): Accessory | |||
@@ -22,4 +30,16 @@ class AccessoryManager extends AbstractManager | |||
$accessory->save(); | |||
return $accessory; | |||
} | |||
public function manageProducts(Accessory $accessory, array $selectedProductsIds = []): void | |||
{ | |||
$this->productAccessoryManager->deleteAllProductAccessoriesByAccessory($accessory); | |||
foreach($selectedProductsIds as $selectedProductId) { | |||
$product = $this->productRepository->findOneProductById($selectedProductId); | |||
if($product) { | |||
$this->productAccessoryManager->createProductAccessory($product, $accessory, 1); | |||
} | |||
} | |||
} | |||
} |
@@ -3,6 +3,8 @@ | |||
namespace domain\Product\Accessory; | |||
use domain\_\AbstractRepository; | |||
use domain\_\RepositoryQueryInterface; | |||
use yii\db\ActiveQuery; | |||
class AccessoryRepository extends AbstractRepository | |||
{ | |||
@@ -23,6 +25,11 @@ class AccessoryRepository extends AbstractRepository | |||
]; | |||
} | |||
public function queryAccessories(): RepositoryQueryInterface | |||
{ | |||
return $this->createDefaultQuery(); | |||
} | |||
public function findOneAccessoryById(int $id): ?Accessory | |||
{ | |||
return $this->createDefaultQuery() |
@@ -0,0 +1,22 @@ | |||
<?php | |||
namespace domain\Product\Product; | |||
use domain\_\AbstractManager; | |||
use domain\Product\Accessory\Accessory; | |||
use domain\Product\ProductAccessory\ProductAccessoryManager; | |||
class ProductManager extends AbstractManager | |||
{ | |||
protected ProductAccessoryManager $productAccessoryManager; | |||
public function loadDependencies(): void | |||
{ | |||
$this->productAccessoryManager = $this->loadService(ProductAccessoryManager::class); | |||
} | |||
public function needAccessory(Product $product, Accessory $accessory, int $quantity): void | |||
{ | |||
$this->productAccessoryManager->createProductAccessoryIfNotExist($product, $accessory, $quantity); | |||
} | |||
} |
@@ -12,8 +12,9 @@ class ProductModule extends AbstractModule | |||
return [ | |||
ProductDefinition::class, | |||
ProductSolver::class, | |||
ProductRepository::class, | |||
ProductBuilder::class, | |||
ProductRepository::class, | |||
ProductManager::class | |||
]; | |||
} | |||
@@ -27,13 +28,18 @@ class ProductModule extends AbstractModule | |||
return ProductSolver::getInstance(); | |||
} | |||
public function getBuilder(): ProductBuilder | |||
{ | |||
return ProductBuilder::getInstance(); | |||
} | |||
public function getRepository(): ProductRepository | |||
{ | |||
return ProductRepository::getInstance(); | |||
} | |||
public function getBuilder(): ProductBuilder | |||
public function getManager(): ProductManager | |||
{ | |||
return ProductBuilder::getInstance(); | |||
return ProductManager::getInstance(); | |||
} | |||
} |
@@ -0,0 +1,86 @@ | |||
<?php | |||
namespace domain\Product\ProductAccessory; | |||
use common\components\ActiveRecordCommon; | |||
use domain\Product\Accessory\Accessory; | |||
use domain\Product\Product\Product; | |||
use yii\db\ActiveQuery; | |||
class ProductAccessory extends ActiveRecordCommon | |||
{ | |||
public static function tableName() | |||
{ | |||
return 'product_accessory'; | |||
} | |||
public function rules() | |||
{ | |||
return [ | |||
[['id_product', 'id_accessory', 'quantity'], 'required'], | |||
[['id_product', 'id_accessory', 'quantity'], 'integer'], | |||
]; | |||
} | |||
public function attributeLabels() | |||
{ | |||
return [ | |||
'id' => 'ID', | |||
'id_product' => 'Produit', | |||
'id_accessory' => 'Accessoire', | |||
'quantity' => 'Quantité', | |||
]; | |||
} | |||
/* Getters / Setters */ | |||
public function getId(): ?int | |||
{ | |||
return $this->id; | |||
} | |||
public function getProduct(): Product | |||
{ | |||
return $this->productRelation; | |||
} | |||
public function setProduct(Product $product): self | |||
{ | |||
$this->populateFieldObject('id_product', 'productRelation', $product); | |||
return $this; | |||
} | |||
public function getAccessory(): Accessory | |||
{ | |||
return $this->accessoryRelation; | |||
} | |||
public function setAccessory(Accessory $accessory): self | |||
{ | |||
$this->populateFieldObject('id_accessory', 'accessoryRelation', $accessory); | |||
return $this; | |||
} | |||
public function getQuantity(): ?int | |||
{ | |||
return $this->quantity; | |||
} | |||
public function setQuantity(?int $quantity): self | |||
{ | |||
$this->quantity = $quantity; | |||
return $this; | |||
} | |||
/* Relations */ | |||
public function getProductRelation(): ActiveQuery | |||
{ | |||
return $this->hasOne(Product::class, ['id' => 'id_product']); | |||
} | |||
public function getAccessoryRelation(): ActiveQuery | |||
{ | |||
return $this->hasOne(Accessory::class, ['id' => 'id_accessory']); | |||
} | |||
} |
@@ -0,0 +1,15 @@ | |||
<?php | |||
namespace domain\Product\ProductAccessory; | |||
use domain\_\AbstractBuilder; | |||
use domain\Product\Product\Product; | |||
class ProductAccessoryBuilder extends AbstractBuilder | |||
{ | |||
public function instanciateProductAccessory(): ProductAccessory | |||
{ | |||
$productAccessory = new ProductAccessory(); | |||
return $productAccessory; | |||
} | |||
} |
@@ -0,0 +1,13 @@ | |||
<?php | |||
namespace domain\Product\ProductAccessory; | |||
use domain\_\AbstractDefinition; | |||
class ProductAccessoryDefinition extends AbstractDefinition | |||
{ | |||
public function getEntityFqcn(): string | |||
{ | |||
return ProductAccessory::class; | |||
} | |||
} |
@@ -0,0 +1,51 @@ | |||
<?php | |||
namespace domain\Product\ProductAccessory; | |||
use domain\_\AbstractManager; | |||
use domain\Product\Accessory\Accessory; | |||
use domain\Product\Product\Product; | |||
class ProductAccessoryManager extends AbstractManager | |||
{ | |||
protected ProductAccessoryBuilder $productAccessoryBuilder; | |||
protected ProductAccessoryRepository $productAccessoryRepository; | |||
public function loadDependencies(): void | |||
{ | |||
$this->productAccessoryBuilder = $this->loadService(ProductAccessoryBuilder::class); | |||
$this->productAccessoryRepository = $this->loadService(ProductAccessoryRepository::class); | |||
} | |||
public function createProductAccessory(Product $product, Accessory $accessory, int $quantity): ProductAccessory | |||
{ | |||
$productAccessory = $this->productAccessoryBuilder->instanciateProductAccessory(); | |||
$productAccessory->setProduct($product); | |||
$productAccessory->setAccessory($accessory); | |||
$productAccessory->setQuantity($quantity); | |||
$productAccessory->save(); | |||
return $productAccessory; | |||
} | |||
public function createProductAccessoryIfNotExist(Product $product, Accessory $accessory, int $quantity): ProductAccessory | |||
{ | |||
$productAccessory = $this->productAccessoryRepository->findOneProductAccessory($product, $accessory); | |||
if($productAccessory) { | |||
$productAccessory->setQuantity($quantity); | |||
$productAccessory->save(); | |||
} | |||
else { | |||
$productAccessory = $this->createProductAccessory($product, $accessory, $quantity); | |||
} | |||
return $productAccessory; | |||
} | |||
public function deleteAllProductAccessoriesByAccessory(Accessory $accessory): void | |||
{ | |||
$productAccessoriesArray = $this->productAccessoryRepository->findProductAccessoriesByAccessory($accessory); | |||
foreach($productAccessoriesArray as $productAccessory) { | |||
$productAccessory->delete(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
<?php | |||
namespace domain\Product\ProductAccessory; | |||
use domain\_\AbstractModule; | |||
class ProductAccessoryModule extends AbstractModule | |||
{ | |||
public function getServices(): array | |||
{ | |||
return [ | |||
ProductAccessoryDefinition::class, | |||
ProductAccessoryBuilder::class, | |||
ProductAccessoryRepository::class, | |||
ProductAccessoryManager::class, | |||
]; | |||
} | |||
public function getDefinition(): ProductAccessoryDefinition | |||
{ | |||
return ProductAccessoryDefinition::getInstance(); | |||
} | |||
public function getBuilder(): ProductAccessoryBuilder | |||
{ | |||
return ProductAccessoryBuilder::getInstance(); | |||
} | |||
public function getRepository(): ProductAccessoryRepository | |||
{ | |||
return ProductAccessoryRepository::getInstance(); | |||
} | |||
public function getManager(): ProductAccessoryManager | |||
{ | |||
return ProductAccessoryManager::getInstance(); | |||
} | |||
} |
@@ -0,0 +1,42 @@ | |||
<?php | |||
namespace domain\Product\ProductAccessory; | |||
use domain\_\AbstractRepository; | |||
use domain\Product\Accessory\Accessory; | |||
use domain\Product\Product\Product; | |||
class ProductAccessoryRepository extends AbstractRepository | |||
{ | |||
protected ProductAccessoryRepositoryQuery $query; | |||
public function loadDependencies(): void | |||
{ | |||
$this->loadQuery(ProductAccessoryRepositoryQuery::class); | |||
} | |||
public function getDefaultOptionsSearch(): array | |||
{ | |||
return [ | |||
self::WITH => [], | |||
self::JOIN_WITH => ['accessoryRelation'], | |||
self::ORDER_BY => 'accessory.name ASC', | |||
self::ATTRIBUTE_ID_PRODUCER => '' | |||
]; | |||
} | |||
public function findOneProductAccessory(Product $product, Accessory $accessory): ?ProductAccessory | |||
{ | |||
return $this->createDefaultQuery() | |||
->filterByProduct($product) | |||
->filterByAccessory($accessory) | |||
->findOne(); | |||
} | |||
public function findProductAccessoriesByAccessory(Accessory $accessory): array | |||
{ | |||
return $this->createDefaultQuery() | |||
->filterByAccessory($accessory) | |||
->find(); | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
<?php | |||
namespace domain\Product\ProductAccessory; | |||
use domain\_\AbstractRepositoryQuery; | |||
use domain\Product\Accessory\Accessory; | |||
use domain\Product\Product\Product; | |||
class ProductAccessoryRepositoryQuery extends AbstractRepositoryQuery | |||
{ | |||
protected ProductAccessoryDefinition $definition; | |||
public function loadDependencies(): void | |||
{ | |||
$this->loadDefinition(ProductAccessoryDefinition::class); | |||
} | |||
public function filterByProduct(Product $product): self | |||
{ | |||
$this->andWhere(['product_accessory.id_product' => $product->id]); | |||
return $this; | |||
} | |||
public function filterByAccessory(Accessory $accessory): self | |||
{ | |||
$this->andWhere(['product_accessory.id_accessory' => $accessory->id]); | |||
return $this; | |||
} | |||
} |