diff --git a/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/OrdersRelationManager.php b/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/OrdersRelationManager.php index 99b114b773..52dea82322 100644 --- a/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/OrdersRelationManager.php +++ b/packages/admin/src/Filament/Resources/CustomerResource/RelationManagers/OrdersRelationManager.php @@ -5,6 +5,7 @@ use Filament\Tables; use Filament\Tables\Table; use Lunar\Admin\Filament\Resources\OrderResource; +use Lunar\Admin\Filament\Resources\OrderResource\Pages\ManageOrder; use Lunar\Admin\Support\RelationManagers\BaseRelationManager; use Lunar\Admin\Filament\Resources\OrderResource\Pages\ManageOrder; use Lunar\Models\Order; diff --git a/packages/admin/src/Filament/Resources/ProductResource.php b/packages/admin/src/Filament/Resources/ProductResource.php index c11b1fab6a..ff3fb21d69 100644 --- a/packages/admin/src/Filament/Resources/ProductResource.php +++ b/packages/admin/src/Filament/Resources/ProductResource.php @@ -313,7 +313,8 @@ public static function getNameTableColumn(): Tables\Columns\Column ->attributeData() ->limitedTooltip() ->limit(50) - ->label(__('lunarpanel::product.table.name.label')); + ->label(__('lunarpanel::product.table.name.label')) + ->searchable(); } public static function getSkuTableColumn(): Tables\Columns\Column @@ -336,7 +337,8 @@ public static function getSkuTableColumn(): Tables\Columns\Column }) ->listWithLineBreaks() ->limitList(1) - ->toggleable(); + ->toggleable() + ->searchable(); } public static function getDefaultRelations(): array diff --git a/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php b/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php index f02e59b67f..f994e004ee 100644 --- a/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php +++ b/packages/admin/src/Filament/Resources/ProductResource/Pages/ListProducts.php @@ -27,7 +27,7 @@ protected function getDefaultHeaderActions(): array static::createActionFormInputs() )->using( fn (array $data, string $model) => static::createRecord($data, $model) - )->successRedirectUrl(fn (Model $record): string => route('filament.lunar.resources.products.edit', [ + )->successRedirectUrl(fn (Model $record): string => ProductResource::getUrl('edit', [ 'record' => $record, ])), ]; diff --git a/packages/admin/src/Support/Forms/Components/Attributes.php b/packages/admin/src/Support/Forms/Components/Attributes.php index e57ad4ee1a..898c287572 100644 --- a/packages/admin/src/Support/Forms/Components/Attributes.php +++ b/packages/admin/src/Support/Forms/Components/Attributes.php @@ -85,7 +85,7 @@ protected function setUp(): void } foreach ($state as $key => $value) { - if (! $value instanceof \Lunar\Base\Fieldtype) { + if (! $value instanceof \Lunar\Base\FieldType) { continue; } diff --git a/packages/core/database/state/EnsureMediaCollectionsAreRenamed.php b/packages/core/database/state/EnsureMediaCollectionsAreRenamed.php index 9701b71553..3993a6bea0 100644 --- a/packages/core/database/state/EnsureMediaCollectionsAreRenamed.php +++ b/packages/core/database/state/EnsureMediaCollectionsAreRenamed.php @@ -35,7 +35,7 @@ protected function shouldRun() protected function getOutdatedMediaQuery() { return DB::table(app(config('media-library.media_model'))->getTable()) - ->whereIn('model_type', [Product::class, Collection::class, Brand::class]) + ->whereIn('model_type', [Product::morphName(), Collection::morphName(), Brand::morphName()]) ->where('collection_name', 'products'); } } diff --git a/packages/core/src/DiscountTypes/AbstractDiscountType.php b/packages/core/src/DiscountTypes/AbstractDiscountType.php index 8e0d3305b5..868313bb49 100644 --- a/packages/core/src/DiscountTypes/AbstractDiscountType.php +++ b/packages/core/src/DiscountTypes/AbstractDiscountType.php @@ -64,7 +64,7 @@ protected function checkDiscountConditions(Cart $cart): bool $validCoupon = $cartCoupon ? ($cartCoupon === $conditionCoupon) : blank($conditionCoupon); - $minSpend = ($data['min_prices'][$cart->currency->code] ?? 0) / $cart->currency->factor; + $minSpend = (int) ($data['min_prices'][$cart->currency->code] ?? 0) / (int) $cart->currency->factor; $minSpend = (int) bcmul($minSpend, $cart->currency->factor); $lines = $this->getEligibleLines($cart); diff --git a/packages/core/src/Observers/OrderLineObserver.php b/packages/core/src/Observers/OrderLineObserver.php index 967607dd53..af384a4281 100644 --- a/packages/core/src/Observers/OrderLineObserver.php +++ b/packages/core/src/Observers/OrderLineObserver.php @@ -32,8 +32,12 @@ public function creating(OrderLine $orderLine) */ public function updating(OrderLine $orderLine) { - if (! in_array(Purchasable::class, class_implements($orderLine->purchasable_type, true))) { - throw new NonPurchasableItemException($orderLine->purchasable_type); + $purchasableModel = class_exists($orderLine->purchasable_type) ? + $orderLine->purchasable_type : + Relation::getMorphedModel($orderLine->purchasable_type); + + if (! $purchasableModel || ! in_array(Purchasable::class, class_implements($purchasableModel, true))) { + throw new NonPurchasableItemException($purchasableModel); } } }