feat: implement inventory management controllers, dispatch service logic, and frontend inventory tracking dashboard
Some checks failed
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled
Tests / PHP 8.5 (push) Has been cancelled

This commit is contained in:
Ajjj
2026-08-05 16:23:57 +08:00
parent 6075ac7632
commit c13f418517
4 changed files with 53 additions and 14 deletions

View File

@@ -7,12 +7,13 @@ use Illuminate\Http\Request;
use Inertia\Inertia;
use Modules\MaterialLogistics\Models\InventoryMovement;
use Modules\MaterialLogistics\Models\Warehouse;
use Modules\ProjectManagement\Models\Project;
class WarehouseController extends Controller
{
public function index(Request $request)
{
$query = Warehouse::query();
$query = Warehouse::whereIn('id', $this->visibleWarehouseIdsQuery());
if ($search = $request->search) {
$query->where(function ($q) use ($search) {
@@ -40,6 +41,8 @@ class WarehouseController extends Controller
public function show(Request $request, Warehouse $warehouse)
{
abort_unless($this->visibleWarehouseIdsQuery()->where('warehouses.id', $warehouse->id)->exists(), 403);
// Paginated stock with search & category filter
$stockQuery = $warehouse->stock()->with([
'material:id,ulid,name,sku,unit,category,type',
@@ -94,6 +97,13 @@ class WarehouseController extends Controller
]);
}
private function visibleWarehouseIdsQuery()
{
return Warehouse::query()
->whereIn('project_id', Project::query()->select('projects.id'))
->select('warehouses.id');
}
public function store(Request $request)
{
$validated = $request->validate([