Skip to content

Commit

Permalink
feat: add thumbnail to varaint, and move storage config from core to …
Browse files Browse the repository at this point in the history
…media config file
  • Loading branch information
mckenziearts committed Dec 5, 2024
1 parent 7bac523 commit 03dd5cc
Show file tree
Hide file tree
Showing 28 changed files with 108 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class="text-xs font-medium uppercase leading-4 tracking-wider text-gray-500 dark
<div class="shrink-0">
<img
class="size-8 rounded-full object-cover"
src="{{ $item->product->getFirstMediaUrl(config('shopper.core.storage.thumbnail_collection')) }}"
src="{{ $item->product->getFirstMediaUrl(config('shopper.media.storage.thumbnail_collection')) }}"
alt="{{ $item->name }}"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="relative">
<div class="h-70 overflow-hidden rounded-lg bg-gray-100 dark:bg-gray-800">
<img
src="{{ $relatedProduct->getFirstMediaUrl(config('shopper.core.storage.thumbnail_collection')) }}"
src="{{ $relatedProduct->getFirstMediaUrl(config('shopper.media.storage.thumbnail_collection')) }}"
alt="{{ $relatedProduct->name }} Thumbnail"
class="h-full w-full max-w-none object-cover object-center"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class="!w-20"
<div class="shrink-0">
<img
class="size-10 rounded-lg object-cover"
src="{{ $item->product->getFirstMediaUrl(config('shopper.core.storage.thumbnail_collection')) }}"
src="{{ $item->product->getFirstMediaUrl(config('shopper.media.storage.thumbnail_collection')) }}"
alt="{{ $item->name }}"
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="flex items-center gap-2">
<img
class="size-8 rounded-full object-cover"
src="{{ $firstItem->product->getFirstMediaUrl(config('shopper.core.storage.thumbnail_collection')) }}"
src="{{ $firstItem->product->getFirstMediaUrl(config('shopper.media.storage.thumbnail_collection')) }}"
alt="Avatar {{ $firstItem->product->name }}"
/>

Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Livewire/Components/Account/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function form(Form $form): Form
->avatar()
->image()
->maxSize(1024)
->disk(config('shopper.core.storage.disk_name')),
->disk(config('shopper.media.storage.disk_name')),
Components\Grid::make()
->schema([
Components\TextInput::make('first_name')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function table(Table $table): Table
->columns([
Tables\Columns\SpatieMediaLibraryImageColumn::make('thumbnail')
->label(__('shopper::forms.label.thumbnail'))
->collection(config('shopper.core.storage.thumbnail_collection'))
->collection(config('shopper.media.storage.thumbnail_collection'))
->circular()
->defaultImageUrl(shopper_fallback_url()),
Tables\Columns\TextColumn::make('name'),
Expand Down
7 changes: 4 additions & 3 deletions packages/admin/src/Livewire/Components/Products/Form/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,12 @@ public function form(Form $form): Form
->relationship(
relationship: 'categories',
titleAttribute: 'name',
parentAttribute: 'parent_id'
parentAttribute: 'parent_id',
modifyQueryUsing: fn (Builder $query) => $query->where('is_enabled', true)
)
->searchable()
->independent(false)
->enableBranchNode()
->grouped(false)
->searchable()
->visible(Feature::enabled('category')),
])
->visible(
Expand Down
10 changes: 5 additions & 5 deletions packages/admin/src/Livewire/Components/Products/Form/Media.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\SpatieMediaLibraryFileUpload::make('media')
->collection(config('shopper.core.storage.collection_name'))
Forms\Components\SpatieMediaLibraryFileUpload::make('images')
->collection(config('shopper.media.storage.collection_name'))
->label(__('shopper::words.images'))
->helperText(__('shopper::pages/products.images_helpText'))
->multiple()
->panelLayout('grid')
->maxSize(config('shopper.media.max_size.images'))
->columnSpan(['lg' => 2]),

Forms\Components\SpatieMediaLibraryFileUpload::make('thumbnail')
->collection(config('shopper.core.storage.thumbnail_collection'))
->collection(config('shopper.media.storage.thumbnail_collection'))
->label(__('shopper::forms.label.thumbnail'))
->helperText(__('shopper::pages/products.thumbnail_helpText'))
->image()
->maxSize(1024)
->imageEditor()
->maxSize(config('shopper.media.max_size.thumbnail'))
->columnSpan(['lg' => 1]),
])
->columns(3)
Expand Down
14 changes: 4 additions & 10 deletions packages/admin/src/Livewire/Components/Products/Form/Variants.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,18 @@ public function table(Table $table): Table
->newQuery()
)
->columns([
Tables\Columns\SpatieMediaLibraryImageColumn::make('images')
->collection(config('shopper.core.storage.collection_name'))
->stacked()
->circular()
->wrap()
->defaultImageUrl(shopper_fallback_url()),

Tables\Columns\SpatieMediaLibraryImageColumn::make('thumbnail')
->collection(config('shopper.media.storage.thumbnail_collection'))
->label(__('shopper::forms.label.thumbnail'))
->circular(),
Tables\Columns\TextColumn::make('name')
->label(__('shopper::forms.label.name'))
->searchable()
->sortable(),

Tables\Columns\TextColumn::make('sku')
->label(__('shopper::layout.tables.sku'))
->searchable()
->sortable(),

Tables\Columns\TextColumn::make('stock')
->label(__('shopper::layout.tables.current_stock'))
->formatStateUsing(
Expand All @@ -70,7 +65,6 @@ public function table(Table $table): Table
</div>
BLADE))
),

Tables\Columns\TextColumn::make('price_amount')
->label(__('shopper::forms.label.price'))
->money(shopper_currency())
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Livewire/Modals/PaymentMethodForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function form(Form $form): Form
->avatar()
->image()
->maxSize(1024)
->disk(config('shopper.core.storage.disk_name'))
->disk(config('shopper.media.storage.disk_name'))
->columnSpan('full'),
Components\TextInput::make('title')
->label(__('shopper::forms.label.payment_method'))
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Livewire/Pages/Brand/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function table(Table $table): Table
->query((new BrandRepository)->query())
->columns([
Tables\Columns\SpatieMediaLibraryImageColumn::make('Logo')
->collection(config('shopper.core.storage.thumbnail_collection'))
->collection(config('shopper.media.storage.thumbnail_collection'))
->circular()
->defaultImageUrl(shopper_fallback_url())
->grow(false),
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Livewire/Pages/Category/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function table(Table $table): Table
)
->columns([
Tables\Columns\SpatieMediaLibraryImageColumn::make('image')
->collection(config('shopper.core.storage.thumbnail_collection'))
->collection(config('shopper.media.storage.thumbnail_collection'))
->circular()
->defaultImageUrl(shopper_fallback_url())
->grow(false),
Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Livewire/Pages/Collection/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function form(Form $form): Form
->schema([
Forms\Components\SpatieMediaLibraryFileUpload::make('file')
->label(__('shopper::forms.label.image_preview'))
->collection(config('shopper.core.storage.thumbnail_collection'))
->collection(config('shopper.media.storage.thumbnail_collection'))
->image()
->maxSize(1024),

Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Livewire/Pages/Collection/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function table(Table $table): Table
)
->columns([
Tables\Columns\SpatieMediaLibraryImageColumn::make('image')
->collection(config('shopper.core.storage.thumbnail_collection'))
->collection(config('shopper.media.storage.thumbnail_collection'))
->circular()
->defaultImageUrl(shopper_fallback_url())
->grow(false),
Expand Down
15 changes: 8 additions & 7 deletions packages/admin/src/Livewire/Pages/Product/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,21 +127,21 @@ public function form(Form $form): Form
Components\Wizard\StepColumn::make(__('shopper::words.media'))
->icon('untitledui-image')
->schema([
Forms\Components\SpatieMediaLibraryFileUpload::make('media')
->collection(config('shopper.core.storage.collection_name'))
Forms\Components\SpatieMediaLibraryFileUpload::make('images')
->collection(config('shopper.media.storage.collection_name'))
->label(__('shopper::words.images'))
->helperText(__('shopper::pages/products.images_helpText'))
->multiple()
->panelLayout('grid')
->maxSize(config('shopper.media.max_size.images'))
->columnSpan(['lg' => 3]),

Forms\Components\SpatieMediaLibraryFileUpload::make('thumbnail')
->collection(config('shopper.core.storage.thumbnail_collection'))
->collection(config('shopper.media.storage.thumbnail_collection'))
->label(__('shopper::forms.label.thumbnail'))
->helperText(__('shopper::pages/products.thumbnail_helpText'))
->image()
->maxSize(1024)
->imageEditor()
->maxSize(config('shopper.media.max_size.thumbnail'))
->columnSpan(['lg' => 2]),
])
->columns(5),
Expand All @@ -167,10 +167,11 @@ public function form(Form $form): Form
->relationship(
relationship: 'categories',
titleAttribute: 'name',
parentAttribute: 'parent_id'
parentAttribute: 'parent_id',
modifyQueryUsing: fn (Builder $query) => $query->where('is_enabled', true)
)
->independent(false)
->enableBranchNode()
->grouped(false)
->searchable()
->visible(Feature::enabled('category')),
])
Expand Down
12 changes: 2 additions & 10 deletions packages/admin/src/Livewire/Pages/Product/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,47 +44,39 @@ public function table(Table $table): Table
)
->columns([
Tables\Columns\SpatieMediaLibraryImageColumn::make('thumbnail')
->collection(config('shopper.media.storage.thumbnail_collection'))
->label(__('shopper::forms.label.thumbnail'))
->circular()
->collection(config('shopper.core.storage.thumbnail_collection'))
->defaultImageUrl(shopper_fallback_url()),

->circular(),
Tables\Columns\TextColumn::make('name')
->label(__('shopper::forms.label.name'))
->searchable()
->toggleable()
->sortable(),

Tables\Columns\TextColumn::make('price_amount')
->label(__('shopper::forms.label.price'))
->money(currency: shopper_currency())
->sortable(),

Tables\Columns\IconColumn::make('is_visible')
->label(__('shopper::forms.label.availability'))
->sortable()
->toggleable(),

Tables\Columns\TextColumn::make('brand.name')
->label(__('shopper::forms.label.brand'))
->searchable()
->sortable()
->toggleable(Feature::enabled('brand'))
->hidden(! Feature::enabled('brand')),

Tables\Columns\ViewColumn::make('stock')
->label(__('shopper::layout.tables.stock'))
->toggleable()
->view('shopper::livewire.tables.cells.products.stock')
->toggledHiddenByDefault(),

Tables\Columns\TextColumn::make('sku')
->label(__('shopper::layout.tables.sku'))
->searchable()
->sortable()
->toggleable()
->toggledHiddenByDefault(),

Tables\Columns\TextColumn::make('published_at')
->label(__('shopper::forms.label.published_at'))
->searchable()
Expand Down
20 changes: 11 additions & 9 deletions packages/admin/src/Livewire/Pages/Product/Variant.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,19 @@ public function form(Form $form): Form
->afterStateUpdated(function ($state, Forms\Set $set): void {
$set('slug', Str::slug($state));
}),

Forms\Components\TextInput::make('slug')
->label(__('shopper::forms.label.slug'))
->disabled()
->dehydrated()
->required()
->maxLength(255)
->unique(config('shopper.models.product'), 'slug', ignoreRecord: true),

Forms\Components\TextInput::make('price_amount') // @phpstan-ignore-line
->label(__('shopper::forms.label.price_amount'))
->numeric()
->rules(['regex:/^\d{1,6}(\.\d{0,2})?$/'])
->suffix(shopper_currency())
->currencyMask(thousandSeparator: ',', decimalSeparator: '.', precision: 2),

Forms\Components\TextInput::make('old_price_amount') // @phpstan-ignore-line
->label(__('shopper::forms.label.compare_price'))
->numeric()
Expand All @@ -86,16 +83,23 @@ public function form(Form $form): Form

Components\Separator::make(),

Components\Section::make(__('shopper::words.images'))
Components\Section::make(__('shopper::words.media'))
->compact()
->aside()
->schema([
Forms\Components\SpatieMediaLibraryFileUpload::make('thumbnail')
->collection(config('shopper.media.storage.thumbnail_collection'))
->label(__('shopper::forms.label.thumbnail'))
->helperText(__('shopper::pages/products.thumbnail_helpText'))
->image()
->maxSize(config('shopper.media.max_size.thumbnail')),
Forms\Components\SpatieMediaLibraryFileUpload::make('images')
->multiple()
->hiddenLabel()
->label(__('shopper::words.images'))
->panelLayout('grid')
->helperText(__('shopper::pages/products.variant_images_helpText'))
->collection(config('shopper.core.storage.collection_name'))
->maxSize(1024),
->collection(config('shopper.media.storage.collection_name'))
->maxSize(config('shopper.media.max_size.images')),
]),

Components\Separator::make(),
Expand All @@ -111,12 +115,10 @@ public function form(Form $form): Form
->unique(config('shopper.models.product'), 'sku', ignoreRecord: true)
->required()
->maxLength(255),

Forms\Components\TextInput::make('barcode')
->label(__('shopper::forms.label.barcode'))
->unique(config('shopper.models.product'), 'barcode', ignoreRecord: true)
->maxLength(255),

Forms\Components\TextInput::make('security_stock')
->label(__('shopper::forms.label.safety_stock'))
->numeric()
Expand Down
Loading

0 comments on commit 03dd5cc

Please sign in to comment.