Skip to content

Commit

Permalink
Added channelable PaymentMethod & ShippingMethod models to Foundation
Browse files Browse the repository at this point in the history
  • Loading branch information
fulopattila122 committed Sep 8, 2023
1 parent ef7907e commit 4241015
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
- Added the `withImages` method to the product search class (eager loads media)
- Added the `channelables` table for being many-to-many polymorphic relationships with channels and arbitrary models
- Added the `mapInto()` method to the `RelationAdjustmentCollection` class, which forwards the call to the underlying Eloquent collection
- Added the `Channelable` behavior to Foundation Product, MasterProduct and Taxonomy classes
- Added the `Channelable` behavior to Foundation Product, MasterProduct, PaymentMethod, ShippingMethod and Taxonomy classes
- Added and extended Foundation Channel model that contains the known relationships to the "channelable" models
- Added the `withinChannel[s]` methods to the ProductSearch class
- Added the `Features` accessor class, which is a syntactic sugar for areas of the configuration
Expand Down
23 changes: 23 additions & 0 deletions src/Foundation/Models/PaymentMethod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

/**
* Contains the PaymentMethod class.
*
* @copyright Copyright (c) 2023 Vanilo UG
* @author Attila Fulop
* @license MIT
* @since 2023-09-08
*
*/

namespace Vanilo\Foundation\Models;

use Vanilo\Channel\Traits\Channelable;
use Vanilo\Payment\Models\PaymentMethod as BasePaymentMethod;

class PaymentMethod extends BasePaymentMethod
{
use Channelable;
}
23 changes: 23 additions & 0 deletions src/Foundation/Models/ShippingMethod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

/**
* Contains the ShippingMethod class.
*
* @copyright Copyright (c) 2023 Vanilo UG
* @author Attila Fulop
* @license MIT
* @since 2023-09-08
*
*/

namespace Vanilo\Foundation\Models;

use Vanilo\Channel\Traits\Channelable;
use Vanilo\Shipment\Models\ShippingMethod as BaseShippingMethod;

class ShippingMethod extends BaseShippingMethod
{
use Channelable;
}
10 changes: 10 additions & 0 deletions src/Foundation/Providers/ModuleServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
use Vanilo\Foundation\Models\MasterProductVariant;
use Vanilo\Foundation\Models\Order;
use Vanilo\Foundation\Models\OrderItem;
use Vanilo\Foundation\Models\PaymentMethod;
use Vanilo\Foundation\Models\Product;
use Vanilo\Foundation\Models\Shipment;
use Vanilo\Foundation\Models\ShippingMethod;
use Vanilo\Foundation\Models\Taxon;
use Vanilo\Foundation\Models\Taxonomy;
use Vanilo\Foundation\Shipping\FlatFeeCalculator;
Expand All @@ -52,10 +54,14 @@
use Vanilo\Order\Contracts\OrderFactory as OrderFactoryContract;
use Vanilo\Order\Contracts\OrderItem as OrderItemContract;
use Vanilo\Order\Models\OrderProxy;
use Vanilo\Payment\Contracts\PaymentMethod as PaymentMethodContract;
use Vanilo\Payment\Models\PaymentMethodProxy;
use Vanilo\Product\Contracts\Product as ProductContract;
use Vanilo\Product\Models\ProductProxy;
use Vanilo\Shipment\Contracts\Shipment as ShipmentContract;
use Vanilo\Shipment\Contracts\ShippingMethod as ShippingMethodContract;
use Vanilo\Shipment\Models\ShipmentProxy;
use Vanilo\Shipment\Models\ShippingMethodProxy;
use Vanilo\Shipment\ShippingFeeCalculators;

class ModuleServiceProvider extends BaseBoxServiceProvider
Expand Down Expand Up @@ -86,6 +92,8 @@ public function boot()
$this->concord->registerModel(ShipmentContract::class, Shipment::class, $registerRouteModels);
$this->concord->registerModel(MasterProductContract::class, MasterProduct::class, $registerRouteModels);
$this->concord->registerModel(MasterProductVariantContract::class, MasterProductVariant::class, $registerRouteModels);
$this->concord->registerModel(ShippingMethodContract::class, ShippingMethod::class, $registerRouteModels);
$this->concord->registerModel(PaymentMethodContract::class, PaymentMethod::class, $registerRouteModels);

Relation::morphMap([
// @todo remove this bullshit in v4. It's not event part of the interface
Expand All @@ -97,6 +105,8 @@ public function boot()
'order' => OrderProxy::modelClass(),
'cart' => CartProxy::modelClass(),
'shipment' => ShipmentProxy::modelClass(),
'shipping_method' => ShippingMethodProxy::modelClass(),
'payment_method' => PaymentMethodProxy::modelClass(),
'channel' => ChannelProxy::modelClass(),
]);

Expand Down

0 comments on commit 4241015

Please sign in to comment.