Skip to content

Commit

Permalink
update container resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
repl6669 committed Sep 4, 2024
1 parent f7d1722 commit 48e8f96
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/Base/OrderReferenceGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,22 @@
namespace Lunar\Base;

use Lunar\Facades\DB;
use Lunar\Models\Contracts\Order as OrderContract;
use Lunar\Models\Order;

class OrderReferenceGenerator implements OrderReferenceGeneratorInterface
{
/**
* {@inheritDoc}
*/
public function generate(Order $order): string
public function generate(OrderContract $order): string
{
/** @var Order $order */
$year = $order->created_at->year;

$month = $order->created_at->format('m');

$latest = Order::select(
$latest = Order::modelClass()::select(
DB::RAW('MAX(reference) as reference')
)->whereYear('created_at', '=', $year)
->whereMonth('created_at', '=', $month)
Expand Down
8 changes: 5 additions & 3 deletions packages/stripe/src/Actions/StoreAddressInformation.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Lunar\Stripe\Actions;

use Lunar\Models\Contracts\Order as OrderContract;
use Lunar\Models\Country;
use Lunar\Models\Order;
use Lunar\Models\OrderAddress;
Expand All @@ -10,8 +11,9 @@

class StoreAddressInformation
{
public function store(Order $order, PaymentIntent $paymentIntent)
public function store(OrderContract $order, PaymentIntent $paymentIntent)
{
/** @var Order $order */
$billingAddress = $order->billingAddress ?: new OrderAddress([
'order_id' => $order->id,
'type' => 'billing',
Expand All @@ -25,7 +27,7 @@ public function store(Order $order, PaymentIntent $paymentIntent)
$paymentMethod = Stripe::getPaymentMethod($paymentIntent->payment_method);

if ($paymentIntent->shipping && $stripeShipping = $paymentIntent->shipping->address) {
$country = Country::where('iso2', $stripeShipping->country)->first();
$country = Country::modelClass()::where('iso2', $stripeShipping->country)->first();
$shippingAddress->first_name = explode(' ', $paymentIntent->shipping->name)[0];
$shippingAddress->last_name = explode(' ', $paymentIntent->shipping->name)[1] ?? '';
$shippingAddress->line_one = $stripeShipping->line1;
Expand All @@ -39,7 +41,7 @@ public function store(Order $order, PaymentIntent $paymentIntent)
}

if ($paymentMethod && $stripeBilling = $paymentMethod->billing_details?->address) {
$country = Country::where('iso2', $stripeBilling->country)->first();
$country = Country::modelClass()::where('iso2', $stripeBilling->country)->first();
$billingAddress->first_name = explode(' ', $paymentMethod->billing_details->name)[0];
$billingAddress->last_name = explode(' ', $paymentMethod->billing_details->name)[1] ?? '';
$billingAddress->line_one = $stripeBilling->line1;
Expand Down
4 changes: 2 additions & 2 deletions packages/stripe/src/Jobs/ProcessStripeWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public function handle()
$order = null;

if ($this->orderId) {
$order = Order::find($this->orderId);
$order = Order::modelClass()::find($this->orderId);

if ($order->placed_at) {
return;
}
}

if (! $order) {
$cart = Cart::where('meta->payment_intent', '=', $this->paymentIntentId)->first();
$cart = Cart::modelClass()::where('meta->payment_intent', '=', $this->paymentIntentId)->first();
}

if (! $cart && ! $order) {
Expand Down
4 changes: 2 additions & 2 deletions tests/core/Unit/Models/ProductOptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
$productOption = ProductOption::factory()->create();
$this->assertDatabaseCount((new ProductOption)->getTable(), 1);

ProductOption::where('handle', $productOption->handle)->delete();
ProductOption::modelClass()::where('handle', $productOption->handle)->delete();
$this->assertDatabaseCount((new ProductOption)->getTable(), 0);
});

Expand All @@ -74,7 +74,7 @@
]);

$this->assertDatabaseCount((new ProductOptionValue)->getTable(), 1);
expect(ProductOptionValue::whereRelation(
expect(ProductOptionValue::modelClass()::whereRelation(
'option',
'product_option_id',
$productOption->id)->get())->toHaveCount(1);
Expand Down

0 comments on commit 48e8f96

Please sign in to comment.