Example #1
0
 public static function initialize(Config $config)
 {
     ItemGroupTrait::initialize($config);
     TimestampsTrait::initialize($config);
     RandomKeyTrait::initialize($config);
     $config->setTable('StorePurchase')->addRels([new Rel\BelongsTo('purchase', $config, Purchase::getRepo()), new Rel\BelongsTo('store', $config, Store::getRepo()), new Rel\HasMany('items', $config, PurchaseItem::getRepo(), ['inverseOf' => 'storePurchase']), new Rel\HasMany('refunds', $config, Refund::getRepo(), ['inverseOf' => 'storePurchase'])]);
 }
Example #2
0
 public static function initialize(Config $config)
 {
     ItemTrait::initialize($config);
     InheritedTrait::initialize($config);
     TimestampsTrait::initialize($config);
     $config->addRels([new Rel\BelongsTo('purchase', $config, Purchase::getRepo()), new Rel\BelongsTo('storePurchase', $config, StorePurchase::getRepo())]);
 }
Example #3
0
 /**
  * @covers ::initialize
  */
 public function testInitialize()
 {
     $purchase = Purchase::getRepo();
     $billing = $purchase->getRelOrError('billing');
     $this->assertEquals('CL\\Purchases\\Address', $billing->getRepo()->getModelClass());
     $items = $purchase->getRelOrError('items');
     $this->assertEquals('CL\\Purchases\\PurchaseItem', $items->getRepo()->getModelClass());
     $storePurchases = $purchase->getRelOrError('storePurchases');
     $this->assertEquals('CL\\Purchases\\StorePurchase', $storePurchases->getRepo()->getModelClass());
 }
Example #4
0
 public static function initialize(Config $config)
 {
     SoftDeleteTrait::initialize($config);
     $config->addRels([new Rel\BelongsTo('city', $config, City::getRepo()), new Rel\BelongsTo('country', $config, Country::getRepo()), new Rel\HasOne('purchase', $config, Purchase::getRepo(), ['foreignKey' => 'billingId'])])->addAsserts([new Assert\Present('firstName'), new Assert\Present('lastName'), new Assert\Present('email'), new Assert\Present('phone'), new Assert\Present('postCode'), new Assert\Present('line1'), new Assert\Email('email')]);
 }