Skip to content

Commit

Permalink
Patch beta 03 (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
mckenziearts committed Sep 25, 2023
1 parent a64f130 commit 47efd21
Show file tree
Hide file tree
Showing 47 changed files with 417 additions and 137 deletions.
12 changes: 0 additions & 12 deletions config/core.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,6 @@
'disk_name' => 'public',
],

/*
|--------------------------------------------------------------------------
| Locale Configuration
|--------------------------------------------------------------------------
|
| Shopper PHP locale determines the default locale that will be used
| by the model date format function ->formatLocalized().
|
*/

'locale' => 'en_EN',

/*
|--------------------------------------------------------------------------
| Barcode type
Expand Down
11 changes: 11 additions & 0 deletions config/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,15 @@
],
],

/*
|--------------------------------------------------------------------------
| Fallback image URL
|--------------------------------------------------------------------------
|
| If your media collection does not contain any items, this image should be displayed
|
*/

'fallback' => '/shopper/images/placeholder.jpg',

];
72 changes: 72 additions & 0 deletions config/models.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php

declare(strict_types=1);

return [

/*
|--------------------------------------------------------------------------
| Brand Model
|--------------------------------------------------------------------------
|
| Eloquent model should be used to retrieve your brands. Of course,
| If you want to change this to use a custom model, your model needs to extends the
| \Shopper\Core\Models\Brand model.
|
*/

'brand' => \Shopper\Core\Models\Brand::class,

/*
|--------------------------------------------------------------------------
| Category Model
|--------------------------------------------------------------------------
|
| Eloquent model should be used to retrieve your categories. Of course,
| If you want to change this to use a custom model, your model needs to extends the
| \Shopper\Core\Models\Category model.
|
*/

'category' => \Shopper\Core\Models\Category::class,

/*
|--------------------------------------------------------------------------
| Collection Model
|--------------------------------------------------------------------------
|
| Eloquent model should be used to retrieve your collections. Of course,
| if you want to change this to use a custom model, your model needs to extends the
| \Shopper\Core\Models\Collection model.
|
*/

'collection' => \Shopper\Core\Models\Collection::class,

/*
|--------------------------------------------------------------------------
| Product Model
|--------------------------------------------------------------------------
|
| Eloquent model should be used to retrieve your products. Of course,
| If you want to change this to use a custom model, your model needs to extends the
| \Shopper\Core\Models\Product model.
|
*/

'product' => \Shopper\Core\Models\Product::class,

/*
|--------------------------------------------------------------------------
| Channel Model
|--------------------------------------------------------------------------
|
| Eloquent model should be used to retrieve your channels. Of course,
| If you want to change this to use a custom model, your model needs to extends the
| \Shopper\Core\Models\Channel model.
|
*/

'channel' => \Shopper\Core\Models\Channel::class,

];
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ public function up(): void
$this->addCommonFields($table);

$table->morphs('stockable');
$table->string('reference_type')->nullable();
$table->unsignedBigInteger('reference_id')->nullable();
$table->nullableMorphs('reference');
$table->integer('quantity');
$table->integer('old_quantity')->default(0);
$table->text('event')->nullable();
$table->string('event', 75)->nullable();
$table->text('description')->nullable();

$this->addForeignKey($table, 'inventory_id', $this->getTableName('inventories'), false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function up(): void
$table->enum('type', ['deliverable', 'downloadable'])->nullable();
$table->boolean('backorder')->default(false);
$table->boolean('requires_shipping')->default(false);
$table->dateTimeTz('published_at')->default(now())->nullable();
$table->dateTimeTz('published_at')->default(now());

$this->addSeoFields($table);
$this->addShippingFields($table);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public function up(): void

$table->longText('refund_reason')->nullable();
$table->string('refund_amount')->nullable();
$table->enum('status', ['pending', 'treatment', 'partial-refund', 'refunded', 'cancelled', 'rejected'])->default('pending');
$table->string('status')->default(\Shopper\Core\Enum\OrderRefundStatus::PENDING->value);
$table->longText('notes');

$this->addForeignKey($table, 'order_id', $this->getTableName('orders'), false);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Shopper\Core\Helpers\Migration;

return new class() extends Migration
{
public function up(): void
{
Schema::table($this->getTableName('products'), function (Blueprint $table): void {
$table->renameColumn(from: 'requires_shipping', to: 'require_shipping');
});
}
};
8 changes: 4 additions & 4 deletions database/seeders/LegalsPageTableSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@ public function run(): void

Legal::query()->create([
'title' => $title = __('shopper::pages/settings.legal.refund'),
'slug' => str_slug($title),
'slug' => $title,
'is_enabled' => true,
'content' => null,
]);

Legal::query()->create([
'title' => $title = __('shopper::pages/settings.legal.privacy'),
'slug' => str_slug($title),
'slug' => $title,
'is_enabled' => true,
'content' => null,
]);

Legal::query()->create([
'title' => $title = __('shopper::pages/settings.legal.terms_of_use'),
'slug' => str_slug($title),
'slug' => $title,
'is_enabled' => true,
'content' => null,
]);

Legal::query()->create([
'title' => $title = __('shopper::pages/settings.legal.shipping'),
'slug' => str_slug($title),
'slug' => $title,
'is_enabled' => true,
'content' => null,
]);
Expand Down
5 changes: 3 additions & 2 deletions src/CoreServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@ final class CoreServiceProvider extends ServiceProvider
protected array $configFiles = [
'core',
'media',
'models',
];

protected string $root = __DIR__ . '/..';

public function boot(): void
{
setlocale(LC_TIME, config('shopper.core.locale'));
Carbon::setLocale(config('shopper.core.locale'));
setlocale(LC_ALL, config('app.locale'));
Carbon::setLocale(config('app.locale'));
}

public function register(): void
Expand Down
12 changes: 12 additions & 0 deletions src/Enum/CollectionType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace Shopper\Core\Enum;

enum CollectionType: string
{
case MANUAL = 'manual';

case AUTO = 'auto';
}
22 changes: 22 additions & 0 deletions src/Enum/Dimension/Length.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

namespace Shopper\Core\Enum\Dimension;

use Shopper\Core\Traits\ArrayableEnum;

enum Length: string
{
use ArrayableEnum;

case M = 'm';

case CM = 'cm';

case MM = 'mm';

case FT = 'ft';

case IN = 'in';
}
20 changes: 20 additions & 0 deletions src/Enum/Dimension/Volume.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace Shopper\Core\Enum\Dimension;

use Shopper\Core\Traits\ArrayableEnum;

enum Volume: string
{
use ArrayableEnum;

case L = 'l';

case ML = 'ml';

case GAL = 'gal';

case FLOZ = 'floz';
}
18 changes: 18 additions & 0 deletions src/Enum/Dimension/Weight.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

declare(strict_types=1);

namespace Shopper\Core\Enum\Dimension;

use Shopper\Core\Traits\ArrayableEnum;

enum Weight: string
{
use ArrayableEnum;

case KG = 'kg';

case G = 'g';

case LBS = 'lbs';
}
31 changes: 18 additions & 13 deletions src/Enum/OrderRefundStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,28 @@

namespace Shopper\Core\Enum;

enum OrderRefundStatus
enum OrderRefundStatus: string
{
case PENDING;
case TREATMENT;
case PARTIAL_REFUND;
case REFUNDED;
case REJECTED;
case CANCELLED;

public function value(): string
case PENDING = 'pending';

case TREATMENT = 'treatment';

case PARTIAL_REFUND = 'partial-refund';

case REFUNDED = 'refunded';

case REJECTED = 'rejected';

case CANCELLED = 'cancelled';

public function translateValue(): string
{
return match ($this) {
self::PENDING => __('shopper::status.pending'),
self::TREATMENT => __('Treatment'),
self::PARTIAL_REFUND => __('Partially refunded'),
self::REFUNDED => __('Refunded'),
self::REJECTED => __('Rejected'),
self::TREATMENT => __('shopper::status.treatment'),
self::PARTIAL_REFUND => __('shopper::status.partial-refund'),
self::REFUNDED => __('shopper::status.refunded'),
self::REJECTED => __('shopper::status.rejected'),
self::CANCELLED => __('shopper::status.cancelled'),
};
}
Expand Down
4 changes: 4 additions & 0 deletions src/Enum/OrderStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
enum OrderStatus: string
{
case PENDING = 'pending';

case REGISTER = 'registered';

case PAID = 'completed';

case COMPLETED = 'cancelled';

case CANCELLED = 'paid';

public function badge(): string
Expand Down
13 changes: 8 additions & 5 deletions src/Helpers/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

use Illuminate\Database\Migrations\Migration as BaseMigration;
use Illuminate\Database\Schema\Blueprint;
use Shopper\Core\Enum\Dimension\Length;
use Shopper\Core\Enum\Dimension\Volume;
use Shopper\Core\Enum\Dimension\Weight;

abstract class Migration extends BaseMigration
{
Expand Down Expand Up @@ -39,26 +42,26 @@ public function addSeoFields(Blueprint $table): void

public function addShippingFields(Blueprint $table): void
{
$table->string('weight_unit')->default(Weight::KG->value);
$table->decimal('weight_value', 10, 5)->nullable()
->default(0.00)
->unsigned();
$table->string('weight_unit')->default('kg');
$table->string('height_unit')->default(Length::CM->value);
$table->decimal('height_value', 10, 5)->nullable()
->default(0.00)
->unsigned();
$table->string('height_unit')->default('cm');
$table->string('width_unit')->default(Length::CM->value);
$table->decimal('width_value', 10, 5)->nullable()
->default(0.00)
->unsigned();
$table->string('width_unit')->default('cm');
$table->string('depth_unit')->default(Length::CM->value);
$table->decimal('depth_value', 10, 5)->nullable()
->default(0.00)
->unsigned();
$table->string('depth_unit')->default('cm');
$table->string('volume_unit')->default(Volume::L->value);
$table->decimal('volume_value', 10, 5)->nullable()
->default(0.00)
->unsigned();
$table->string('volume_unit')->default('l');
}

public function addForeignKey(Blueprint $table, string $columnName, string $tableName, bool $nullable = true): void
Expand Down
Loading

0 comments on commit 47efd21

Please sign in to comment.