Преглед на файлове

Produits tournants : modèles + structure + migration

feature/rotating_product
Guillaume Bourgeois преди 4 месеца
родител
ревизия
e4b8278e65
променени са 25 файла, в които са добавени 840 реда и са изтрити 5 реда
  1. +3
    -0
      common/components/BusinessLogic.php
  2. +18
    -0
      common/components/BusinessLogicTrait.php
  3. +61
    -0
      console/migrations/m240702_142432_create_tables_rotating_product.php
  4. +99
    -0
      domain/Distribution/DistributionRotating/DistributionRotating.php
  5. +17
    -0
      domain/Distribution/DistributionRotating/DistributionRotatingBuilder.php
  6. +13
    -0
      domain/Distribution/DistributionRotating/DistributionRotatingDefinition.php
  7. +26
    -0
      domain/Distribution/DistributionRotating/DistributionRotatingManager.php
  8. +32
    -0
      domain/Distribution/DistributionRotating/DistributionRotatingModule.php
  9. +25
    -0
      domain/Distribution/DistributionRotating/DistributionRotatingRepository.php
  10. +15
    -0
      domain/Distribution/DistributionRotating/DistributionRotatingRepositoryQuery.php
  11. +93
    -0
      domain/Product/Rotating/Rotating.php
  12. +19
    -0
      domain/Product/Rotating/RotatingBuilder.php
  13. +13
    -0
      domain/Product/Rotating/RotatingDefinition.php
  14. +24
    -0
      domain/Product/Rotating/RotatingManager.php
  15. +38
    -0
      domain/Product/Rotating/RotatingModule.php
  16. +38
    -0
      domain/Product/Rotating/RotatingRepository.php
  17. +15
    -0
      domain/Product/Rotating/RotatingRepositoryQuery.php
  18. +98
    -0
      domain/Product/RotatingProduct/RotatingProduct.php
  19. +34
    -0
      domain/Product/RotatingProduct/RotatingProductBuilder.php
  20. +13
    -0
      domain/Product/RotatingProduct/RotatingProductDefinition.php
  21. +28
    -0
      domain/Product/RotatingProduct/RotatingProductManager.php
  22. +38
    -0
      domain/Product/RotatingProduct/RotatingProductModule.php
  23. +34
    -0
      domain/Product/RotatingProduct/RotatingProductRepository.php
  24. +22
    -0
      domain/Product/RotatingProduct/RotatingProductRepositoryQuery.php
  25. +24
    -5
      domain/Subscription/ProductSubscription/ProductSubscription.php

+ 3
- 0
common/components/BusinessLogic.php Целия файл

@@ -43,6 +43,8 @@ class BusinessLogic
$this->getPointSaleModule(),
$this->getSharedPointSaleModule(),
$this->getProductModule(),
$this->getRotatingProductModule(),
$this->getRotatingModule(),
$this->getProductOrderModule(),
$this->getOrderStatusModule(),
$this->getOrderStatusHistoryModule(),
@@ -51,6 +53,7 @@ class BusinessLogic
$this->getDeliveryNoteModule(),
$this->getDocumentModule(),
$this->getSubscriptionModule(),
$this->getDistributionRotatingModule(),
$this->getDistributionModule(),
$this->getProducerModule(),
$this->getOrderModule(),

+ 18
- 0
common/components/BusinessLogicTrait.php Целия файл

@@ -6,6 +6,7 @@ use domain\Communication\Email\EmailModule;
use domain\Config\TaxRate\TaxRateModule;
use domain\Config\Unit\UnitModule;
use domain\Distribution\Distribution\DistributionModule;
use domain\Distribution\DistributionRotating\DistributionRotatingModule;
use domain\Distribution\PointSaleDistribution\PointSaleDistributionModule;
use domain\Distribution\ProductDistribution\ProductDistributionModule;
use domain\Document\DeliveryNote\DeliveryNoteModule;
@@ -32,6 +33,8 @@ use domain\Product\ProductAccessory\ProductAccessoryModule;
use domain\Product\ProductCategory\ProductCategoryModule;
use domain\Product\ProductPointSale\ProductPointSaleModule;
use domain\Product\ProductPrice\Module\ProductPriceModule;
use domain\Product\Rotating\RotatingModule;
use domain\Product\RotatingProduct\RotatingProductModule;
use domain\Setting\SettingModule;
use domain\Subscription\ProductSubscription\ProductSubscriptionModule;
use domain\Subscription\Subscription\SubscriptionModule;
@@ -46,6 +49,21 @@ use domain\User\UserUserGroup\UserUserGroupModule;

trait BusinessLogicTrait
{
public function getDistributionRotatingModule(): DistributionRotatingModule
{
return DistributionRotatingModule::getInstance();
}

public function getRotatingProductModule(): RotatingProductModule
{
return RotatingProductModule::getInstance();
}

public function getRotatingModule(): RotatingModule
{
return RotatingModule::getInstance();
}

public function getEmailModule(): EmailModule
{
return EmailModule::getInstance();

+ 61
- 0
console/migrations/m240702_142432_create_tables_rotating_product.php Целия файл

@@ -0,0 +1,61 @@
<?php

use yii\db\Migration;
use yii\db\Schema;

/**
* Class m240702_142432_create_tables_rotating_product
*/
class m240702_142432_create_tables_rotating_product extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->createTable('rotating', [
'id' => 'pk',
'id_producer' => Schema::TYPE_INTEGER.' NOT NULL',
'name' => Schema::TYPE_STRING.' NOT NULL',
'day' => Schema::TYPE_INTEGER.' NOT NULL',
'status' => Schema::TYPE_INTEGER.' NOT NULL',
]);
$this->addForeignKey('rotating_fk_id_producer', 'rotating', 'id_producer', 'producer', 'id');

$this->createTable('rotating_product', [
'id' => 'pk',
'id_rotating' => Schema::TYPE_INTEGER.' NOT NULL',
'id_product' => Schema::TYPE_INTEGER.' NOT NULL',
'position' => Schema::TYPE_INTEGER.' NOT NULL',
'status' => Schema::TYPE_INTEGER.' NOT NULL',
]);
$this->addForeignKey('rotating_product_fk_id_rotating', 'rotating_product', 'id_rotating', 'rotating', 'id');
$this->addForeignKey('rotating_product_fk_id_product', 'rotating_product', 'id_product', 'product', 'id');

$this->createTable('distribution_rotating', [
'id' => 'pk',
'id_distribution' => Schema::TYPE_INTEGER.' NOT NULL',
'id_rotating' => Schema::TYPE_INTEGER.' NOT NULL',
'id_rotating_product' => Schema::TYPE_INTEGER,
'status' => Schema::TYPE_INTEGER.' NOT NULL',
]);
$this->addForeignKey('distribution_rotating_fk_id_distribution', 'distribution_rotating', 'id_distribution', 'distribution', 'id');
$this->addForeignKey('distribution_rotating_fk_id_rotating', 'distribution_rotating', 'id_rotating', 'rotating', 'id');
$this->addForeignKey('distribution_rotating_fk_id_rotating_product', 'distribution_rotating', 'id_rotating_product', 'rotating_product', 'id');

$this->addColumn('product_subscription', 'id_rotating', Schema::TYPE_INTEGER);
$this->addForeignKey('product_subscription_fk_id_rotating', 'product_subscription', 'id_rotating', 'rotating', 'id');
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropTable('rotating');
$this->dropTable('rotating_product');
$this->dropTable('distribution_rotating');

$this->dropColumn('product_subscription', 'id_rotating');
}
}

+ 99
- 0
domain/Distribution/DistributionRotating/DistributionRotating.php Целия файл

@@ -0,0 +1,99 @@
<?php

namespace domain\Distribution\DistributionRotating;

use common\components\ActiveRecordCommon;
use domain\Distribution\Distribution\Distribution;
use domain\Product\Rotating\Rotating;
use domain\Product\RotatingProduct\RotatingProduct;
use yii\db\ActiveQuery;

class DistributionRotating extends ActiveRecordCommon
{
public static function tableName()
{
return 'distribution_rotating';
}

public function rules()
{
return [
[['id_distribution', 'id_rotating'], 'required'],
[['id_distribution', 'id_rotating', 'id_rotating_product', 'status'], 'integer'],
];
}

public function attributeLabels()
{
return [
'id' => 'ID',
'id_distribution' => 'Distribution',
'id_rotating' => 'Produit tournant',
'id_rotating_product' => 'Produit',
'status' => 'Statut',
];
}

/* Getters / Setters */

public function getDistribution(): Distribution
{
return $this->distributionRelation;
}

public function setDistribution(Distribution $distribution): self
{
$this->populateFieldObject('id_distribution', 'distributionRelation', $distribution);
return $this;
}

public function getRotating(): Rotating
{
return $this->rotatingRelation;
}

public function setRotating(Rotating $rotating): self
{
$this->populateFieldObject('id_rotating', 'rotatingRelation', $rotating);
return $this;
}

public function getRotatingProduct(): RotatingProduct
{
return $this->rotatingProductRelation;
}

public function setRotatingProduct(RotatingProduct $rotatingProduct): self
{
$this->populateFieldObject('id_rotating_product', 'rotatingProductRelation', $rotatingProduct);
return $this;
}

public function getStatus(): int
{
return $this->status;
}

public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}

/* Relations */

public function getDistributionRelation(): ActiveQuery
{
return $this->hasOne(Distribution::class, ['id' => 'id_distribution']);
}

public function getRotatingRelation(): ActiveQuery
{
return $this->hasOne(Rotating::class, ['id' => 'id_rotating']);
}

public function getRotatingProductRelation(): ActiveQuery
{
return $this->hasOne(RotatingProduct::class, ['id' => 'id_rotating_product']);
}
}

+ 17
- 0
domain/Distribution/DistributionRotating/DistributionRotatingBuilder.php Целия файл

@@ -0,0 +1,17 @@
<?php

namespace domain\Distribution\DistributionRotating;

use domain\_\AbstractBuilder;
use domain\_\StatusInterface;

class DistributionRotatingBuilder extends AbstractBuilder
{
public function instanciateDistributionRotating(): DistributionRotating
{
$distributionRotating = new DistributionRotating();
$distributionRotating->setStatus(StatusInterface::STATUS_ONLINE);

return $distributionRotating;
}
}

+ 13
- 0
domain/Distribution/DistributionRotating/DistributionRotatingDefinition.php Целия файл

@@ -0,0 +1,13 @@
<?php

namespace domain\Distribution\DistributionRotating;

use domain\_\AbstractDefinition;

class DistributionRotatingDefinition extends AbstractDefinition
{
public function getEntityFqcn(): string
{
return DistributionRotating::class;
}
}

+ 26
- 0
domain/Distribution/DistributionRotating/DistributionRotatingManager.php Целия файл

@@ -0,0 +1,26 @@
<?php

namespace domain\Distribution\DistributionRotating;

use domain\_\AbstractManager;
use domain\Distribution\Distribution\Distribution;
use domain\Product\RotatingProduct\RotatingProduct;

class DistributionRotatingManager extends AbstractManager
{
protected DistributionRotatingBuilder $distributionRotatingBuilder;

public function loadDependencies(): void
{
$this->distributionRotatingBuilder = $this->loadService(DistributionRotatingBuilder::class);
}

public function createDistributionRotating(Distribution $distribution, RotatingProduct $rotatingProduct): DistributionRotating
{
$distributionRotating = $this->distributionRotatingBuilder->instanciateDistributionRotating();
$distributionRotating
->setDistribution($distribution)
->setRotatingProduct($rotatingProduct);
return $distributionRotating;
}
}

+ 32
- 0
domain/Distribution/DistributionRotating/DistributionRotatingModule.php Целия файл

@@ -0,0 +1,32 @@
<?php

namespace domain\Distribution\DistributionRotating;

use domain\_\AbstractModule;

class DistributionRotatingModule extends AbstractModule
{
public function getServices(): array
{
return [
DistributionRotatingDefinition::class,
DistributionRotatingRepository::class,
DistributionRotatingBuilder::class,
];
}

public function getDefinition(): DistributionRotatingDefinition
{
return DistributionRotatingDefinition::getInstance();
}

public function getRepository(): DistributionRotatingRepository
{
return DistributionRotatingRepository::getInstance();
}

public function getBuilder(): DistributionRotatingBuilder
{
return DistributionRotatingBuilder::getInstance();
}
}

+ 25
- 0
domain/Distribution/DistributionRotating/DistributionRotatingRepository.php Целия файл

@@ -0,0 +1,25 @@
<?php

namespace domain\Distribution\DistributionRotating;

use domain\_\AbstractRepository;

class DistributionRotatingRepository extends AbstractRepository
{
protected DistributionRotatingRepositoryQuery $query;

public function loadDependencies(): void
{
$this->loadQuery(DistributionRotatingRepositoryQuery::class);
}

public function getDefaultOptionsSearch(): array
{
return [
self::WITH => [],
self::JOIN_WITH => ['rotatingRelation'],
self::ORDER_BY => 'rotating.name ASC',
self::ATTRIBUTE_ID_PRODUCER => ''
];
}
}

+ 15
- 0
domain/Distribution/DistributionRotating/DistributionRotatingRepositoryQuery.php Целия файл

@@ -0,0 +1,15 @@
<?php

namespace domain\Distribution\DistributionRotating;

use domain\_\AbstractRepositoryQuery;

class DistributionRotatingRepositoryQuery extends AbstractRepositoryQuery
{
protected DistributionRotatingDefinition $definition;

public function loadDependencies(): void
{
$this->loadDefinition(DistributionRotatingDefinition::class);
}
}

+ 93
- 0
domain/Product/Rotating/Rotating.php Целия файл

@@ -0,0 +1,93 @@
<?php

namespace domain\Product\Rotating;

use common\components\ActiveRecordCommon;
use domain\Producer\Producer\Producer;
use yii\db\ActiveQuery;

class Rotating extends ActiveRecordCommon
{
public static function tableName()
{
return 'rotating';
}

public function rules()
{
return [
[['id_producer', 'name', 'day'], 'required'],
[['name'], 'string', 'max' => 255],
[['id_producer', 'day', 'status'], 'integer'],
];
}

public function attributeLabels()
{
return [
'id' => 'ID',
'id_producer' => 'Producteur',
'name' => 'Nom',
'day' => 'Jour',
'status' => 'Statut',
];
}

/* Getters / Setters */

public function getId(): ?int
{
return $this->id;
}

public function getProducer(): Producer
{
return $this->producerRelation;
}

public function setProducer(Producer $producer): self
{
$this->populateFieldObject('id_producer', 'producerRelation', $producer);
return $this;
}

public function getName(): string
{
return $this->name;
}

public function setName(string $name): self
{
$this->name = $name;
return $this;
}

public function getDay(): int
{
return $this->day;
}

public function setDay(int $day): self
{
$this->day = $day;
return $this;
}

public function getStatus(): int
{
return $this->status;
}

public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}

/* Relations */

public function getProducerRelation(): ActiveQuery
{
return $this->hasOne(Producer::class, ['id' => 'id_producer']);
}
}

+ 19
- 0
domain/Product/Rotating/RotatingBuilder.php Целия файл

@@ -0,0 +1,19 @@
<?php

namespace domain\Product\Rotating;

use domain\_\AbstractBuilder;
use domain\_\StatusInterface;
use domain\Producer\Producer\Producer;

class RotatingBuilder extends AbstractBuilder
{
public function instanciateRotating(Producer $producer): Rotating
{
$rotating = new Rotating();
$rotating->setProducer($producer);
$rotating->setStatus(StatusInterface::STATUS_ONLINE);

return $rotating;
}
}

+ 13
- 0
domain/Product/Rotating/RotatingDefinition.php Целия файл

@@ -0,0 +1,13 @@
<?php

namespace domain\Product\Rotating;

use domain\_\AbstractDefinition;

class RotatingDefinition extends AbstractDefinition
{
public function getEntityFqcn(): string
{
return Rotating::class;
}
}

+ 24
- 0
domain/Product/Rotating/RotatingManager.php Целия файл

@@ -0,0 +1,24 @@
<?php

namespace domain\Product\Rotating;

use domain\_\AbstractManager;
use domain\Producer\Producer\Producer;

class RotatingManager extends AbstractManager
{
protected RotatingBuilder $rotatingBuilder;

public function loadDependencies(): void
{
$this->rotatingBuilder = $this->loadService(RotatingBuilder::class);
}

public function createRotating(Producer $producer, string $name, int $day): Rotating
{
$rotating = $this->rotatingBuilder->instanciateRotating($producer, $name, $day);
$rotating->setName($name);
$rotating->setDay($day);
return $rotating;
}
}

+ 38
- 0
domain/Product/Rotating/RotatingModule.php Целия файл

@@ -0,0 +1,38 @@
<?php

namespace domain\Product\Rotating;

use domain\_\AbstractModule;

class RotatingModule extends AbstractModule
{
public function getServices(): array
{
return [
RotatingDefinition::class,
RotatingBuilder::class,
RotatingRepository::class,
RotatingManager::class
];
}

public function getDefinition(): RotatingDefinition
{
return RotatingDefinition::getInstance();
}

public function getBuilder(): RotatingBuilder
{
return RotatingBuilder::getInstance();
}

public function getRepository(): RotatingRepository
{
return RotatingRepository::getInstance();
}

public function getManager(): RotatingManager
{
return RotatingManager::getInstance();
}
}

+ 38
- 0
domain/Product/Rotating/RotatingRepository.php Целия файл

@@ -0,0 +1,38 @@
<?php

namespace domain\Product\Rotating;

use domain\_\AbstractRepository;
use domain\_\RepositoryQueryInterface;

class RotatingRepository extends AbstractRepository
{
protected RotatingRepositoryQuery $query;

public function loadDependencies(): void
{
$this->loadQuery(RotatingRepositoryQuery::class);
}

public function getDefaultOptionsSearch(): array
{
return [
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => 'rotating.name ASC',
self::ATTRIBUTE_ID_PRODUCER => 'rotating.id_producer'
];
}

public function queryRotatings(): RepositoryQueryInterface
{
return $this->createDefaultQuery();
}

public function findOneRotatingById(int $id): ?Rotating
{
return $this->createDefaultQuery()
->filterById($id)
->findOne();
}
}

+ 15
- 0
domain/Product/Rotating/RotatingRepositoryQuery.php Целия файл

@@ -0,0 +1,15 @@
<?php

namespace domain\Product\Rotating;

use domain\_\AbstractRepositoryQuery;

class RotatingRepositoryQuery extends AbstractRepositoryQuery
{
protected RotatingDefinition $definition;

public function loadDependencies(): void
{
$this->loadDefinition(RotatingDefinition::class);
}
}

+ 98
- 0
domain/Product/RotatingProduct/RotatingProduct.php Целия файл

@@ -0,0 +1,98 @@
<?php

namespace domain\Product\RotatingProduct;

use common\components\ActiveRecordCommon;
use domain\Product\Product\Product;
use domain\Product\Rotating\Rotating;
use yii\db\ActiveQuery;

class RotatingProduct extends ActiveRecordCommon
{
public static function tableName()
{
return 'rotating_product';
}

public function rules()
{
return [
[['id_rotating', 'id_product'], 'required'],
[['id_rotating', 'id_product', 'position', 'status'], 'integer'],
];
}

public function attributeLabels()
{
return [
'id' => 'ID',
'id_rotating' => 'Produit tournant',
'id_product' => 'Product',
'position' => 'Position',
'status' => 'Statut',
];
}

/* Getters / Setters */

public function getId(): ?int
{
return $this->id;
}

public function getRotating(): Rotating
{
return $this->rotatingRelation;
}

public function setRotating(Rotating $rotating): self
{
$this->populateFieldObject('id_rotating', 'rotatingRelation', $rotating);
return $this;
}

public function getProduct(): Product
{
return $this->productRelation;
}

public function setProduct(Product $product): self
{
$this->populateFieldObject('id_product', 'productRelation', $product);
return $this;
}

public function getPosition(): int
{
return $this->position;
}

public function setPosition(int $position): self
{
$this->position = $position;
return $this;
}

public function getStatus(): int
{
return $this->status;
}

public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}

/* Relations */

public function getRotatingRelation(): ActiveQuery
{
return $this->hasOne(Rotating::class, ['id' => 'id_rotating']);
}

public function getProductRelation(): ActiveQuery
{
return $this->hasOne(Product::class, ['id' => 'id_product']);
}
}

+ 34
- 0
domain/Product/RotatingProduct/RotatingProductBuilder.php Целия файл

@@ -0,0 +1,34 @@
<?php

namespace domain\Product\RotatingProduct;

use domain\_\AbstractBuilder;
use domain\_\StatusInterface;
use domain\Product\Rotating\Rotating;

class RotatingProductBuilder extends AbstractBuilder
{
protected RotatingProductRepository $rotatingProductRepository;

public function loadDependencies(): void
{
$this->rotatingProductRepository = $this->loadService(RotatingProductRepository::class);
}

public function instanciateRotatingProduct(Rotating $rotating): RotatingProduct
{
$rotatingProduct = new RotatingProduct();
$rotatingProduct
->setRotating($rotating)
->setStatus(StatusInterface::STATUS_ONLINE);

return $rotatingProduct;
}

public function initRotatingProductPosition(RotatingProduct $rotatingProduct): RotatingProduct
{
$lastRotatingProduct = $this->rotatingProductRepository->findOneLastRotatingProduct($rotatingProduct->getRotating());
$rotatingProduct->setPosition($lastRotatingProduct->getPosition() + 1);
return $rotatingProduct;
}
}

+ 13
- 0
domain/Product/RotatingProduct/RotatingProductDefinition.php Целия файл

@@ -0,0 +1,13 @@
<?php

namespace domain\Product\RotatingProduct;

use domain\_\AbstractDefinition;

class RotatingProductDefinition extends AbstractDefinition
{
public function getEntityFqcn(): string
{
return RotatingProduct::class;
}
}

+ 28
- 0
domain/Product/RotatingProduct/RotatingProductManager.php Целия файл

@@ -0,0 +1,28 @@
<?php

namespace domain\Product\RotatingProduct;

use domain\_\AbstractManager;
use domain\_\StatusInterface;
use domain\Product\Product\Product;
use domain\Product\Rotating\Rotating;

class RotatingProductManager extends AbstractManager
{
protected RotatingProductBuilder $rotatingProductBuilder;

public function loadDependencies(): void
{
$this->rotatingProductBuilder = $this->loadService(RotatingProductBuilder::class);
}

public function createRotatingProduct(Rotating $rotating, Product $product): RotatingProduct
{
$rotatingProduct = $this->rotatingProductBuilder->instanciateRotatingProduct($rotating);
$rotatingProduct->setProduct($product);
$this->rotatingProductBuilder->initRotatingProductPosition($rotatingProduct);
$rotatingProduct->save();

return $rotatingProduct;
}
}

+ 38
- 0
domain/Product/RotatingProduct/RotatingProductModule.php Целия файл

@@ -0,0 +1,38 @@
<?php

namespace domain\Product\RotatingProduct;

use domain\_\AbstractModule;

class RotatingProductModule extends AbstractModule
{
public function getServices(): array
{
return [
RotatingProductDefinition::class,
RotatingProductBuilder::class,
RotatingProductRepository::class,
RotatingProductManager::class
];
}

public function getDefinition(): RotatingProductDefinition
{
return RotatingProductDefinition::getInstance();
}

public function getBuilder(): RotatingProductBuilder
{
return RotatingProductBuilder::getInstance();
}

public function getRepository(): RotatingProductRepository
{
return RotatingProductRepository::getInstance();
}

public function getManager(): RotatingProductManager
{
return RotatingProductManager::getInstance();
}
}

+ 34
- 0
domain/Product/RotatingProduct/RotatingProductRepository.php Целия файл

@@ -0,0 +1,34 @@
<?php

namespace domain\Product\RotatingProduct;

use domain\_\AbstractRepository;
use domain\Product\Rotating\Rotating;

class RotatingProductRepository extends AbstractRepository
{
protected RotatingProductRepositoryQuery $query;

public function loadDependencies(): void
{
$this->loadQuery(RotatingProductRepositoryQuery::class);
}

public function getDefaultOptionsSearch(): array
{
return [
self::WITH => [],
self::JOIN_WITH => [],
self::ORDER_BY => 'rotating_product.position ASC',
self::ATTRIBUTE_ID_PRODUCER => ''
];
}

public function findOneLastRotatingProduct(Rotating $rotating): ?RotatingProduct
{
return $this->createQuery()
->filterByRotating($rotating)
->orderBy('rotating_product.position DESC')
->findOne();
}
}

+ 22
- 0
domain/Product/RotatingProduct/RotatingProductRepositoryQuery.php Целия файл

@@ -0,0 +1,22 @@
<?php

namespace domain\Product\RotatingProduct;

use domain\_\AbstractRepositoryQuery;
use domain\Product\Rotating\Rotating;

class RotatingProductRepositoryQuery extends AbstractRepositoryQuery
{
protected RotatingProductDefinition $definition;

public function loadDependencies(): void
{
$this->loadDefinition(RotatingProductDefinition::class);
}

public function filterByRotating(Rotating $rotating): self
{
$this->andWhere(['rotating_product.id_rotating' => $rotating->getId()]);
return $this;
}
}

+ 24
- 5
domain/Subscription/ProductSubscription/ProductSubscription.php Целия файл

@@ -40,6 +40,8 @@ namespace domain\Subscription\ProductSubscription;

use common\components\ActiveRecordCommon;
use domain\Product\Product\Product;
use domain\Product\Rotating\Rotating;
use yii\db\ActiveQuery;

/**
* This is the model class for table "commande_auto_produit".
@@ -60,8 +62,8 @@ class ProductSubscription extends ActiveRecordCommon
public function rules()
{
return [
[['id_subscription', 'id_product'], 'required'],
[['id_subscription', 'id_product'], 'integer'],
[['id_subscription'], 'required'],
[['id_subscription', 'id_product', 'id_rotating'], 'integer'],
[['quantity'], 'number'],
];
}
@@ -75,13 +77,30 @@ class ProductSubscription extends ActiveRecordCommon
'id' => 'ID',
'id_subscription' => 'Abonnement',
'id_product' => 'Produit',
'id_rotating' => 'Produit tournant',
'quantity' => 'Quantité',
];
}

/*
* Relations
*/
/* Getters / setters */

public function getRotating(): ?Rotating
{
return $this->rotatingRelation;
}

public function setRotating(Rotating $rotating): self
{
$this->populateFieldObject('id_rotating', 'rotatingRelation', $rotating);
return $this;
}

/* Relations */

public function getRotatingRelation(): ActiveQuery
{
return $this->hasOne(Rotating::class, ['id' => 'id_rotating']);
}

public function getProduct()
{

Loading…
Отказ
Запис