Skip to content

Commit

Permalink
🎨 Delete unused files and fix product fill casts error (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
mckenziearts committed Sep 28, 2023
1 parent 29362cf commit 2b24aa2
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Shopper\Core\Repositories;
namespace Shopper\Contracts;

interface RepositoryContract
{
Expand Down
17 changes: 17 additions & 0 deletions src/Models/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ class Channel extends Model
'is_default' => 'boolean',
];

protected static function boot(): void
{
parent::boot();

self::creating(function ($channel): void {
if ($channel->is_default) {
static::query()->update(['is_default' => false]);
}
});

self::updating(function ($channel): void {
if ($channel->is_default) {
static::query()->update(['is_default' => false]);
}
});
}

public function getTable(): string
{
return shopper_table('channels');
Expand Down
4 changes: 2 additions & 2 deletions src/Models/Inventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ protected static function boot(): void

self::creating(function ($inventory): void {
if ($inventory->is_default) {
static::query()->update(['is_default' => false]);
Inventory::query()->update(['is_default' => false]);
}
});

self::updating(function ($inventory): void {
if ($inventory->is_default) {
static::query()->update(['is_default' => false]);
Inventory::query()->update(['is_default' => false]);
}
});
}
Expand Down
7 changes: 0 additions & 7 deletions src/Models/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
use Shopper\Core\Contracts\ReviewRateable;
use Shopper\Core\Enum\Dimension\Length;
use Shopper\Core\Enum\Dimension\Volume;
use Shopper\Core\Enum\Dimension\Weight;
use Shopper\Core\Helpers\Price;
use Shopper\Core\Traits\CanHaveDiscount;
use Shopper\Core\Traits\HasMedia;
Expand Down Expand Up @@ -53,10 +50,6 @@ class Product extends Model implements SpatieHasMedia, ReviewRateable
'requires_shipping' => 'boolean',
'backorder' => 'boolean',
'published_at' => 'datetime',
'depth_unit' => Length::class,
'height_unit' => Length::class,
'volume_unit' => Volume::class,
'weight_unit' => Weight::class,
];

public function getTable(): string
Expand Down
1 change: 1 addition & 0 deletions src/Repositories/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Shopper\Contracts\RepositoryContract;
use Shopper\Core\Exceptions\GeneralException;

abstract class BaseRepository implements RepositoryContract
Expand Down
15 changes: 0 additions & 15 deletions src/Repositories/DiscountRepository.php

This file was deleted.

15 changes: 0 additions & 15 deletions src/Repositories/InventoryHistoryRepository.php

This file was deleted.

15 changes: 0 additions & 15 deletions src/Repositories/InventoryRepository.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Shopper\Core\Repositories\Ecommerce;
namespace Shopper\Core\Repositories\Store;

use Shopper\Core\Repositories\BaseRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Shopper\Core\Repositories\Ecommerce;
namespace Shopper\Core\Repositories\Store;

use Shopper\Core\Repositories\BaseRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Shopper\Core\Repositories\Ecommerce;
namespace Shopper\Core\Repositories\Store;

use Shopper\Core\Repositories\BaseRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Shopper\Core\Repositories\Ecommerce;
namespace Shopper\Core\Repositories\Store;

use Shopper\Core\Repositories\BaseRepository;

Expand Down
2 changes: 1 addition & 1 deletion src/Traits/Attributes/WithChoicesCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Shopper\Core\Traits\Attributes;

use Shopper\Core\Repositories\Ecommerce\CategoryRepository;
use Shopper\Core\Repositories\Store\CategoryRepository;

trait WithChoicesCategories
{
Expand Down

0 comments on commit 2b24aa2

Please sign in to comment.