Skip to content

Commit

Permalink
Merge branch '1.x' into fix/product-variant-attribute-filling
Browse files Browse the repository at this point in the history
  • Loading branch information
alecritson authored Nov 4, 2024
2 parents 311a5fe + d01de0d commit 74d0975
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 4 additions & 2 deletions packages/admin/src/Filament/Resources/ProductResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -336,7 +337,8 @@ public static function getSkuTableColumn(): Tables\Columns\Column
})
->listWithLineBreaks()
->limitList(1)
->toggleable();
->toggleable()
->searchable();
}

public static function getDefaultRelations(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
])),
];
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Support/Forms/Components/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
2 changes: 1 addition & 1 deletion packages/core/src/DiscountTypes/AbstractDiscountType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/Observers/OrderLineObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit 74d0975

Please sign in to comment.