feat: implement inventory management controllers, dispatch service logic, and frontend inventory tracking dashboard
This commit is contained in:
@@ -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([
|
||||
|
||||
Reference in New Issue
Block a user