diff --git a/src/Clusters/Product/Resources/ProductResource.php b/src/Clusters/Product/Resources/ProductResource.php index 36eef3f..79cda73 100644 --- a/src/Clusters/Product/Resources/ProductResource.php +++ b/src/Clusters/Product/Resources/ProductResource.php @@ -147,7 +147,14 @@ public static function basicInfoFields() : array ->required() ->inline() ->boolean() - ->default(false) + ->default(false), + + Forms\Components\Radio::make('is_brand_new') + ->label(__('red-jasmine-product::product.fields.is_brand_new')) + ->required() + ->inline() + ->boolean() + ->default(false) , @@ -863,16 +870,20 @@ public static function publishFields() : array public static function table(Table $table) : Table { + return $table ->deferLoading() ->columns([ + ...static::ownerTableColumns(), Tables\Columns\TextColumn::make('id') ->label(__('red-jasmine-product::product.fields.id')) ->sortable(), - ...static::ownerTableColumns(), Tables\Columns\TextColumn::make('title') ->label(__('red-jasmine-product::product.fields.title')) + ->copyable() ->searchable(), + + Tables\Columns\ImageColumn::make('image')->label(__('red-jasmine-product::product.fields.image')), Tables\Columns\TextColumn::make('product_type') @@ -1010,7 +1021,7 @@ public static function table(Table $table) : Table }) ->action(function (Model $record, Tables\Actions\Action $action) { - $status = ($record->status === ProductStatusEnum::ON_SALE) ? ProductStatusEnum::OFF_SHELF : ProductStatusEnum::ON_SALE; + $status = ($record->status === ProductStatusEnum::ON_SALE) ? ProductStatusEnum::DISCONTINUED : ProductStatusEnum::ON_SALE; $command = ProductSetStatusCommand::from([ 'id' => $record->id, 'status' => $status ]); $service = app(static::$commandService); $service->setStatus($command); diff --git a/src/Clusters/Product/Resources/ProductResource/Pages/ListProducts.php b/src/Clusters/Product/Resources/ProductResource/Pages/ListProducts.php index 1545620..4509771 100644 --- a/src/Clusters/Product/Resources/ProductResource/Pages/ListProducts.php +++ b/src/Clusters/Product/Resources/ProductResource/Pages/ListProducts.php @@ -18,10 +18,21 @@ class ListProducts extends ListRecords public function getTabs() : array { return [ - 'all' => Tab::make()->label(__('red-jasmine-product::product.scopes.all')), - 'sale' => Tab::make()->label(__('red-jasmine-product::product.scopes.sale'))->modifyQueryUsing(fn(Builder $query) => $query->sale()), - 'off_shelf' => Tab::make()->label(__('red-jasmine-product::product.scopes.off_shelf'))->modifyQueryUsing(fn(Builder $query) => $query->offShelf()), - 'draft' => Tab::make()->label(__('red-jasmine-product::product.scopes.draft'))->modifyQueryUsing(fn(Builder $query) => $query->draft()), + 'all' => Tab::make() + ->label(__('red-jasmine-product::product.scopes.all')), + 'on-sale' => Tab::make() + ->badge(static::getResource()::getEloquentQuery()->onSale()->count()) + ->label(__('red-jasmine-product::product.scopes.on-sale')) + ->modifyQueryUsing(fn(Builder $query) => $query->onSale()), + 'sold-out' => Tab::make()->label(__('red-jasmine-product::product.scopes.sold-out')) + ->badge(static::getResource()::getEloquentQuery()->soldOut()->count()) + ->modifyQueryUsing(fn(Builder $query) => $query->soldOut()), + 'warehoused' => Tab::make()->label(__('red-jasmine-product::product.scopes.warehoused')) + ->badge(static::getResource()::getEloquentQuery()->warehoused()->count()) + ->modifyQueryUsing(fn(Builder $query) => $query->warehoused()), +// 'stock-alarming' => Tab::make()->label(__('red-jasmine-product::product.scopes.stock-alarming')) +// ->badge(static::getResource()::getEloquentQuery()->stockAlarming()->count()) +// ->modifyQueryUsing(fn(Builder $query) => $query->stockAlarming()), ]; } diff --git a/src/Clusters/Product/Resources/ProductStockResource.php b/src/Clusters/Product/Resources/ProductStockResource.php index 671bf33..80ac042 100644 --- a/src/Clusters/Product/Resources/ProductStockResource.php +++ b/src/Clusters/Product/Resources/ProductStockResource.php @@ -36,7 +36,6 @@ class ProductStockResource extends Resource protected static ?int $navigationSort = 1; - public static function getModelLabel() : string { return __('red-jasmine-product::product-stock.labels.product-stock'); @@ -52,7 +51,6 @@ public static function table(Table $table) : Table { return $table - ->striped() ->columns([ Tables\Columns\TextColumn::make('id')