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
* 🎨 Delete unused files and fix product fill casts error

* Fix php stan

* fix code formatting

---------

Co-authored-by: mckenziearts <[email protected]>
  • Loading branch information
mckenziearts and mckenziearts authored Sep 28, 2023
1 parent c007803 commit 5394b64
Show file tree
Hide file tree
Showing 51 changed files with 100 additions and 135 deletions.
6 changes: 3 additions & 3 deletions packages/admin/src/Http/Controllers/DiscountController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Shopper\Http\Controllers;

use Illuminate\Contracts\View\View;
use Shopper\Core\Repositories\DiscountRepository;
use Shopper\Core\Models\Discount;

final class DiscountController extends ShopperBaseController
{
Expand All @@ -23,12 +23,12 @@ public function create(): View
return view('shopper::pages.discounts.create');
}

public function edit(int $id): View
public function edit(Discount $discount): View
{
$this->authorize('edit_discounts');

return view('shopper::pages.discounts.edit', [
'discount' => (new DiscountRepository())->getById($id),
'discount' => $discount,
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Shopper\Http\Controllers\Ecommerce;

use Illuminate\Contracts\View\View;
use Shopper\Core\Repositories\Ecommerce\BrandRepository;
use Shopper\Core\Repositories\Store\BrandRepository;
use Shopper\Http\Controllers\ShopperBaseController;

final class BrandController extends ShopperBaseController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Shopper\Http\Controllers\Ecommerce;

use Illuminate\Contracts\View\View;
use Shopper\Core\Repositories\Ecommerce\CategoryRepository;
use Shopper\Core\Repositories\Store\CategoryRepository;
use Shopper\Http\Controllers\ShopperBaseController;

final class CategoryController extends ShopperBaseController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Shopper\Http\Controllers\Ecommerce;

use Illuminate\Contracts\View\View;
use Shopper\Core\Repositories\Ecommerce\CollectionRepository;
use Shopper\Core\Repositories\Store\CollectionRepository;
use Shopper\Http\Controllers\ShopperBaseController;

final class CollectionController extends ShopperBaseController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Shopper\Http\Controllers\Ecommerce;

use Illuminate\Contracts\View\View;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\Store\ProductRepository;
use Shopper\Http\Controllers\ShopperBaseController;

final class ProductController extends ShopperBaseController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Contracts\View\View;
use Livewire\Component;
use Shopper\Core\Repositories\Ecommerce\BrandRepository;
use Shopper\Core\Repositories\Store\BrandRepository;

class Browse extends Component
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Contracts\View\View;
use Shopper\Contracts\HasForm;
use Shopper\Core\Repositories\Ecommerce\BrandRepository;
use Shopper\Core\Repositories\Store\BrandRepository;
use Shopper\Core\Traits\Attributes\WithSeoAttributes;
use Shopper\Http\Livewire\AbstractBaseComponent;

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

use Illuminate\Contracts\View\View;
use Livewire\Component;
use Shopper\Core\Repositories\Ecommerce\CategoryRepository;
use Shopper\Core\Repositories\Store\CategoryRepository;

class Browse extends Component
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Contracts\View\View;
use Shopper\Contracts\HasForm;
use Shopper\Core\Repositories\Ecommerce\CategoryRepository;
use Shopper\Core\Repositories\Store\CategoryRepository;
use Shopper\Core\Traits\Attributes\WithChoicesCategories;
use Shopper\Core\Traits\Attributes\WithSeoAttributes;
use Shopper\Http\Livewire\AbstractBaseComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Contracts\View\View;
use Shopper\Contracts\HasForm;
use Shopper\Core\Repositories\Ecommerce\CategoryRepository;
use Shopper\Core\Repositories\Store\CategoryRepository;
use Shopper\Core\Traits\Attributes\WithChoicesCategories;
use Shopper\Core\Traits\Attributes\WithSeoAttributes;
use Shopper\Http\Livewire\AbstractBaseComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Contracts\View\View;
use Livewire\Component;
use Shopper\Core\Repositories\Ecommerce\CollectionRepository;
use Shopper\Core\Repositories\Store\CollectionRepository;

class Browse extends Component
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Shopper\Core\Enum\CollectionType;
use Shopper\Core\Models\Collection;
use Shopper\Core\Models\CollectionRule;
use Shopper\Core\Repositories\Ecommerce\CollectionRepository;
use Shopper\Core\Repositories\Store\CollectionRepository;
use Shopper\Core\Traits\Attributes\WithConditions;
use Shopper\Core\Traits\Attributes\WithSeoAttributes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Carbon\Carbon;
use Illuminate\Contracts\View\View;
use Illuminate\Validation\Rule;
use Shopper\Core\Repositories\Ecommerce\CollectionRepository;
use Shopper\Core\Repositories\Store\CollectionRepository;
use Shopper\Core\Traits\Attributes\WithConditions;
use Shopper\Core\Traits\Attributes\WithSeoAttributes;
use Shopper\Http\Livewire\AbstractBaseComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Shopper\Core\Models\Discount;
use Shopper\Core\Models\DiscountDetail;
use Shopper\Core\Models\User;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\Store\ProductRepository;
use Shopper\Core\Repositories\UserRepository;
use Shopper\Core\Traits\HasPrice;
use Shopper\Http\Livewire\AbstractBaseComponent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Shopper\Http\Livewire\Components\Discounts;

use Carbon\Carbon;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\Store\ProductRepository;
use Shopper\Core\Repositories\UserRepository;

trait WithDiscountActions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Illuminate\Database\Eloquent\Model;
use Livewire\Component;
use Shopper\Core\Models\AttributeProduct;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\Store\ProductRepository;

final class MultipleChoice extends Component
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Contracts\View\View;
use Livewire\Component;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\Store\ProductRepository;

class Browse extends Component
{
Expand Down
16 changes: 8 additions & 8 deletions packages/admin/src/Http/Livewire/Components/Products/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

use Illuminate\Contracts\View\View;
use Milon\Barcode\Facades\DNS1DFacade;
use Shopper\Core\Models\Channel;
use Shopper\Core\Models\Inventory;
use Shopper\Core\Models\Product;
use Shopper\Core\Repositories\Ecommerce\BrandRepository;
use Shopper\Core\Repositories\Ecommerce\CategoryRepository;
use Shopper\Core\Repositories\Ecommerce\CollectionRepository;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\ChannelRepository;
use Shopper\Core\Repositories\Store\BrandRepository;
use Shopper\Core\Repositories\Store\CategoryRepository;
use Shopper\Core\Repositories\Store\CollectionRepository;
use Shopper\Core\Repositories\Store\ProductRepository;
use Shopper\Core\Traits\Attributes\WithChoicesBrands;
use Shopper\Core\Traits\Attributes\WithSeoAttributes;
use Shopper\Http\Livewire\AbstractBaseComponent;
Expand All @@ -23,7 +23,7 @@ class Create extends AbstractBaseComponent
use WithChoicesBrands;
use WithSeoAttributes;

public ?Channel $defaultChannel = null;
public $defaultChannel;

public array $category_ids = [];

Expand All @@ -46,8 +46,8 @@ class Create extends AbstractBaseComponent

public function mount(): void
{
$this->defaultChannel = Channel::query()
->where('slug', 'web-store')
$this->defaultChannel = (new ChannelRepository())
->where('is_default', true)
->first();
}

Expand Down
8 changes: 4 additions & 4 deletions packages/admin/src/Http/Livewire/Components/Products/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Collection;
use Livewire\Component;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\InventoryRepository;
use Shopper\Core\Models\Inventory;
use Shopper\Core\Repositories\Store\ProductRepository;

class Edit extends Component
{
Expand All @@ -23,8 +23,8 @@ class Edit extends Component
public function mount($product): void
{
$this->product = $product;
$this->inventories = $inventories = (new InventoryRepository())->get();
$this->inventory = $inventories->firstWhere('is_default', true)->id ?? $inventories->first()?->id; // @phpstan-ignore-line
$this->inventories = $inventories = Inventory::all();
$this->inventory = $inventories->firstWhere('is_default', true)->id ?? $inventories->first()?->id;
}

public function productHasUpdated(int $id): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
use Livewire\WithFileUploads;
use Shopper\Core\Events\Products\Updated;
use Shopper\Core\Exceptions\GeneralException;
use Shopper\Core\Repositories\Ecommerce\BrandRepository;
use Shopper\Core\Repositories\Ecommerce\CategoryRepository;
use Shopper\Core\Repositories\Ecommerce\CollectionRepository;
use Shopper\Core\Repositories\Store\BrandRepository;
use Shopper\Core\Repositories\Store\CategoryRepository;
use Shopper\Core\Repositories\Store\CollectionRepository;
use Shopper\Core\Traits\Attributes\WithChoicesBrands;
use Shopper\Core\Traits\Attributes\WithSeoAttributes;
use Shopper\Core\Traits\Attributes\WithUploadProcess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
use Livewire\Component;
use Livewire\WithPagination;
use Milon\Barcode\Facades\DNS1DFacade;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\InventoryHistoryRepository;
use Shopper\Core\Models\InventoryHistory;
use Shopper\Core\Traits\Attributes\WithStock;
use Shopper\Http\Livewire\Components\Products\WithAttributes;

Expand Down Expand Up @@ -55,7 +54,7 @@ public function store(): void
],
]);

(new ProductRepository())->getById($this->product->id)->update([
$this->product->update([
'sku' => $this->sku ?? null,
'barcode' => $this->barcode ?? null,
'security_stock' => $this->securityStock ?? null,
Expand All @@ -70,15 +69,15 @@ public function store(): void
public function render(): View
{
return view('shopper::livewire.products.forms.form-inventory', [
'currentStock' => (new InventoryHistoryRepository())
'currentStock' => InventoryHistory::query()
->where('inventory_id', $this->inventory)
->where('stockable_id', $this->product->id)
->get()
->sum('quantity'),
'histories' => (new InventoryHistoryRepository())
'histories' => InventoryHistory::query()
->where('inventory_id', $this->inventory)
->where('stockable_id', $this->product->id)
->orderBy('created_at', 'desc')
->orderByDesc('created_at')
->paginate(5),
'barcodeImage' => $this->barcode
? DNS1DFacade::getBarcodeHTML($this->barcode, config('shopper.core.barcode_type')) // @phpstan-ignore-line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Illuminate\Contracts\View\View;
use Illuminate\Validation\Rule;
use Livewire\Component;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\Store\ProductRepository;
use Shopper\Core\Traits\Attributes\WithSeoAttributes;

class Seo extends Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Filament\Notifications\Notification;
use Illuminate\Contracts\View\View;
use Livewire\Component;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\Store\ProductRepository;
use Shopper\Http\Livewire\Components\Products\WithAttributes;

class Shipping extends Component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Livewire\WithFileUploads;
use Livewire\WithPagination;
use Shopper\Core\Events\Products\Deleted as ProductDeleted;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\Store\ProductRepository;
use Shopper\Core\Traits\Attributes\WithUploadProcess;
use Shopper\Http\Livewire\Components\Products\WithAttributes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Livewire\Component;
use Livewire\WithFileUploads;
use Shopper\Core\Events\Products\Updated as ProductUpdated;
use Shopper\Core\Repositories\InventoryRepository;
use Shopper\Core\Models\Inventory;
use Shopper\Core\Traits\Attributes\WithUploadProcess;

class Variant extends Component
Expand All @@ -37,7 +37,7 @@ class Variant extends Component

public function mount($product, $variant, string $currency): void
{
$this->inventories = (new InventoryRepository())->get(['name', 'id']);
$this->inventories = Inventory::query()->select(['name', 'id'])->get();
$this->product = $product;
$this->variant = $variant;
$this->name = $variant->name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use Illuminate\Contracts\View\View;
use Livewire\Component;
use Livewire\WithPagination;
use Shopper\Core\Repositories\InventoryHistoryRepository;
use Shopper\Core\Repositories\InventoryRepository;
use Shopper\Core\Models\Inventory;
use Shopper\Core\Models\InventoryHistory;
use Shopper\Core\Traits\Attributes\WithStock;

class VariantStock extends Component
Expand All @@ -33,17 +33,17 @@ public function paginationView(): string
public function render(): View
{
return view('shopper::livewire.products.variant-stock', [
'currentStock' => (new InventoryHistoryRepository())
'currentStock' => InventoryHistory::query()
->where('inventory_id', $this->inventory)
->where('stockable_id', $this->product->id)
->get()
->sum('quantity'),
'histories' => (new InventoryHistoryRepository())
'histories' => InventoryHistory::query()
->where('inventory_id', $this->inventory)
->where('stockable_id', $this->product->id)
->orderBy('created_at', 'desc')
->orderByDesc('created_at')
->paginate(3),
'inventories' => (new InventoryRepository())->all(),
'inventories' => Inventory::all(),
]);
}
}
6 changes: 3 additions & 3 deletions packages/admin/src/Http/Livewire/Modals/AddVariant.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use Filament\Notifications\Notification;
use Illuminate\Contracts\View\View;
use LivewireUI\Modal\ModalComponent;
use Shopper\Core\Models\Inventory;
use Shopper\Core\Models\Product;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\InventoryRepository;
use Shopper\Core\Repositories\Store\ProductRepository;
use Shopper\Http\Livewire\Components\Products\WithAttributes;

class AddVariant extends ModalComponent
Expand Down Expand Up @@ -105,7 +105,7 @@ public static function modalMaxWidth(): string
public function render(): View
{
return view('shopper::livewire.modals.add-variant', [
'inventories' => (new InventoryRepository())->get(),
'inventories' => Inventory::all(),
]);
}
}
2 changes: 1 addition & 1 deletion packages/admin/src/Http/Livewire/Modals/DeleteProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Illuminate\Contracts\View\View;
use LivewireUI\Modal\ModalComponent;
use Shopper\Core\Events\Products\Deleted as ProductDeleted;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\Store\ProductRepository;

class DeleteProduct extends ModalComponent
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Illuminate\Contracts\View\View;
use LivewireUI\Modal\ModalComponent;
use Shopper\Core\Repositories\Ecommerce\ProductRepository;
use Shopper\Core\Repositories\Store\ProductRepository;

class DiscountProducts extends ModalComponent
{
Expand Down
Loading

0 comments on commit 5394b64

Please sign in to comment.