Add stock items, groups and movements at a moving average cost
Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Inventory\Infrastructure\Providers;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Modules\Catalog\Application\Contracts\CatalogQueries;
|
||||
use App\Modules\Inventory\Application\Contracts\StockItemImages;
|
||||
use App\Modules\Inventory\Application\Contracts\StockQueries;
|
||||
use App\Modules\Inventory\Domain\Contracts\StockItemGroupRepository;
|
||||
use App\Modules\Inventory\Domain\Contracts\StockItemRepository;
|
||||
use App\Modules\Inventory\Domain\Contracts\StockMovementRepository;
|
||||
use App\Modules\Inventory\Infrastructure\Files\StockItemImageFiles;
|
||||
use App\Modules\Inventory\Infrastructure\Persistence\Repositories\EloquentStockItemGroupRepository;
|
||||
use App\Modules\Inventory\Infrastructure\Persistence\Repositories\EloquentStockItemRepository;
|
||||
use App\Modules\Inventory\Infrastructure\Persistence\Repositories\EloquentStockMovementRepository;
|
||||
use App\Modules\Inventory\Infrastructure\Persistence\Repositories\EloquentStockQueries;
|
||||
use App\Modules\Users\Domain\Enums\Role;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Livewire\Livewire;
|
||||
|
||||
/**
|
||||
* Wires the Inventory module (stock items, movements and stock counts,
|
||||
* spec 19.1–19.3) into Laravel: bindings, routes, the `inventory::`
|
||||
* Livewire namespace and the `inventory.*` abilities (spec 19.9).
|
||||
*/
|
||||
class InventoryServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* @var array<class-string, class-string>
|
||||
*/
|
||||
public array $bindings = [
|
||||
StockItemGroupRepository::class => EloquentStockItemGroupRepository::class,
|
||||
StockItemRepository::class => EloquentStockItemRepository::class,
|
||||
StockMovementRepository::class => EloquentStockMovementRepository::class,
|
||||
StockQueries::class => EloquentStockQueries::class,
|
||||
StockItemImages::class => StockItemImageFiles::class,
|
||||
];
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
$presentationPath = dirname(__DIR__, 2).'/Presentation';
|
||||
|
||||
Livewire::addNamespace('inventory', viewPath: $presentationPath.'/Livewire');
|
||||
|
||||
if (! $this->app->routesAreCached()) {
|
||||
$this->loadRoutesFrom($presentationPath.'/Routes/web.php');
|
||||
}
|
||||
|
||||
$staff = fn (User $user): bool => $user->role !== Role::Subcontractor;
|
||||
$managers = fn (User $user): bool => in_array($user->role, [Role::Admin, Role::Management], true);
|
||||
|
||||
Gate::define('inventory.view', $staff);
|
||||
Gate::define('inventory.record-use', $staff);
|
||||
Gate::define('inventory.count', $staff);
|
||||
Gate::define('inventory.manage', $managers);
|
||||
Gate::define('inventory.manage-counts', $managers);
|
||||
Gate::define('inventory.reverse-any', $managers);
|
||||
Gate::define('inventory.see-value', $managers);
|
||||
|
||||
// The menu shows stock pages only when a service unit uses stock (spec 19).
|
||||
Gate::define('inventory.menu', fn (User $user): bool => $staff($user) && app(CatalogQueries::class)->stockServiceUnitIds() !== []);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user