Skip to content

Commit

Permalink
feat: Update product media layout and add new PaymentMethod seeder class
Browse files Browse the repository at this point in the history
  • Loading branch information
mckenziearts committed Jul 19, 2024
1 parent 321a46c commit aefa1ea
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function form(Form $form): Form
->label(__('shopper::words.images'))
->helperText(__('shopper::pages/products.images_helpText'))
->multiple()
->panelLayout('grid')
->columnSpan(['lg' => 2]),

Forms\Components\SpatieMediaLibraryFileUpload::make('thumbnail')
Expand Down
7 changes: 4 additions & 3 deletions packages/admin/src/Livewire/Pages/Product/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function form(Form $form): Form
->label(__('shopper::words.images'))
->helperText(__('shopper::pages/products.images_helpText'))
->multiple()
->panelLayout('grid')
->columnSpan(['lg' => 3]),

Forms\Components\SpatieMediaLibraryFileUpload::make('thumbnail')
Expand All @@ -152,7 +153,7 @@ public function form(Form $form): Form

Forms\Components\Select::make('collections')
->label(__('shopper::pages/collections.menu'))
->relationship('collections', 'name', fn (Builder $query) => $query->where('is_enabled', true))
->relationship('collections', 'name')
->searchable()
->multiple()
->visible(Feature::enabled('collection')),
Expand Down Expand Up @@ -291,7 +292,7 @@ public function store(): void

$product->channels()->sync([$this->defaultChannel->id]);

if (Feature::enabled('category') && array_key_exists('categories', $data) && count($data['categories']) > 0) {
if (Feature::enabled('category') && array_key_exists('categories', $data) && is_array($data['categories'])) {
$product->categories()->sync($data['categories']);
}

Expand All @@ -302,7 +303,7 @@ public function store(): void
}

Notification::make()
->title(__('shopper::pages/products.notifications.create'))
->title(__('shopper::notifications.create', ['item' => $product->name]))
->success()
->send();

Expand Down
2 changes: 1 addition & 1 deletion packages/admin/src/Livewire/Pages/Product/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function table(Table $table): Table
->columns([
Tables\Columns\SpatieMediaLibraryImageColumn::make('thumbnail')
->label(__('shopper::forms.label.thumbnail'))
->square()
->circular()
->collection(config('shopper.core.storage.thumbnail_collection'))
->defaultImageUrl(shopper_fallback_url()),

Expand Down
20 changes: 20 additions & 0 deletions packages/core/database/seeders/PaymentMethodSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Shopper\Core\Database\Seeders;

use Illuminate\Database\Seeder;
use Shopper\Core\Models\PaymentMethod;

final class PaymentMethodSeeder extends Seeder
{
public function run(): void
{
PaymentMethod::query()->create([
'title' => 'Cash',
'slug' => 'cash',
'is_enabled' => true,
]);
}
}
1 change: 1 addition & 0 deletions packages/core/database/seeders/ShopperSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public function run(): void
$this->call(LegalsPageTableSeeder::class);
$this->call(ChannelSeeder::class);
$this->call(CarrierSeeder::class);
$this->call(PaymentMethodSeeder::class);

Model::reguard();
}
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,13 @@ function shopper_asset(string $file): string
if (! function_exists('shopper_currency')) {
function shopper_currency(): string
{
$settingCurrency = shopper_setting('default_currency_id');
$currencyId = shopper_setting('default_currency_id');

if ($settingCurrency) {
if ($currencyId) {
$currency = Cache::remember(
'shopper-currency',
now()->addHour(),
fn () => Currency::query()->find($settingCurrency)
fn () => Currency::query()->find($currencyId)
);

return $currency ? $currency->code : 'USD'; // @phpstan-ignore-line
Expand Down

0 comments on commit aefa1ea

Please sign in to comment.