C:\Users\user\Documents\GitHub\Restaurent-Management-Sysytem\app\Http\Controllers\ItemTransactionController.php

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Models\ItemTransaction;
use App\Models\ItemMaster;
use App\Models\Branch;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Auth;

class ItemTransactionController extends Controller
{

    /**
     * Get stock summary statistics for dashboard
     */
    protected function getStockStatistics()
    {
        $totalItems      = ItemMaster::count();
        $inStockCount    = 0;
        $nearReorderCount = 0;
        $outOfStockCount = 0;

        // Loop through each item (across all branches) to compute these stats
        $items = ItemMaster::all();
        foreach ($items as $item) {
            // stock across all branches
            $stock = ItemTransaction::stockOnHand($item->id);

            if ($stock <= 0) {
                $outOfStockCount++;
            } elseif ($stock <= $item->reorder_level) {
                $nearReorderCount++;
            } else {
                $inStockCount++;
            }
        }

        return compact('totalItems', 'inStockCount', 'nearReorderCount', 'outOfStockCount');
    }


    /**
     * Display a listing of item transactions grouped by item & branch.
     */
    public function index()
    {
        // Get statistics for dashboard
        $stats    = $this->getStockStatistics();
        $search   = request('search');
        $branchId = request('branch_id');
        $status   = request('status');

        $query = ItemMaster::with(['category', 'transactions']);

        if ($search) {
            $query->where('name', 'like', "%{$search}%")
                ->orWhere('item_code', 'like', "%{$search}%");
        }

        $items = $query->get();

        $stockData = [];

        foreach ($items as $item) {
            $branchesQuery = $branchId
                ? Branch::where('id', $branchId)
                : Branch::active();

            foreach ($branchesQuery->get() as $branch) {
                $currentStock = ItemTransaction::stockOnHand($item->id, $branch->id);

                // skip if nothing at all
                if (
                    $currentStock <= 0
                    && ! $item->transactions()->where('branch_id', $branch->id)->exists()
                ) {
                    continue;
                }

                // determine status
                $statusValue = $currentStock <= 0
                    ? 'out_of_stock'
                    : ($currentStock <= $item->reorder_level ? 'low_stock' : 'in_stock');

                // apply status filter
                if ($status && $statusValue !== $status) {
                    continue;
                }

                $stockData[] = [
                    'item'          => $item,
                    'branch'        => $branch,
                    'current_stock' => $currentStock,
                    'reorder_level' => $item->reorder_level,
                    'status'        => $statusValue,
                ];
            }
        }

        // Paginate the resulting array
        $perPage       = 25;
        $currentPage   = LengthAwarePaginator::resolveCurrentPage();
        $itemsForPage  = array_slice($stockData, ($currentPage - 1) * $perPage, $perPage);
        $stocks        = new LengthAwarePaginator(
            $itemsForPage,
            count($stockData),
            $perPage,
            $currentPage,
            ['path' => request()->url(), 'query' => request()->query()]
        );

        // Fetch branches for the filter dropdown
        $branches = Branch::active()->get();

        return view('admin.inventory.stock.index', [
            'stocks' => $stocks,
            'stats' => $stats, 
            'branches' => $branches,
            'itemsCount' => $stats['totalItems'],
            'inStockCount' => $stats['inStockCount'],
            'nearReorderCount' => $stats['nearReorderCount'],
            'outOfStockCount' => $stats['outOfStockCount']
        ]);
    }

    public function transactions()
    {
        $query = ItemTransaction::with(['item', 'branch'])->latest();

        if (request('search')) {
            $query->whereHas('item', function ($q) {
                $q->where('name', 'like', '%' . request('search') . '%');
            });
        }

        if (request('branch_id')) {
            $query->where('branch_id', request('branch_id'));
        }

        $transactions = $query->paginate(25);
        $branches = Branch::active()->get(); // Make sure Branch model has active() scope

        return view('admin.inventory.stock.transactions.index', compact('transactions', 'branches'));
    }

    public function stockSummary()
    {
        $items = ItemMaster::with('category')->get();

        $stockData = $items->map(function ($item) {
            $stock = ItemTransaction::stockOnHand($item->id);
            return [
                'name' => $item->name,
                'category' => optional($item->category)->name ?? '-',
                'reorder_level' => $item->reorder_level,
                'stock' => $stock,
                'status' => $stock <= $item->reorder_level ? 'Warning' : 'OK',
            ];
        });

        return response()->json($stockData);
    }

    public function create()
    {
        $items = ItemMaster::all();
        $branches = Branch::active()->get();
        return view('admin.inventory.stock.create', compact('items', 'branches'));
    }

    /**
     * Store a newly created transaction.
     */
    public function store(Request $request)
    {
        $validated = $request->validate([
            'inventory_item_id' => 'required|exists:item_master,id',
            'branch_id' => 'required|exists:branches,id',
            'transaction_type' => 'required|in:in,out',
            'quantity' => 'required|numeric|min:0.01',
            'notes' => 'nullable|string',
        ]);

        $validated['created_by_user_id'] = auth()->id();
        $validated['is_active'] = true;

        ItemTransaction::create($validated);

        return redirect()->route('admin.inventory.stock.index')
            ->with('success', 'Transaction recorded successfully.');
    }

    public function show(ItemTransaction $transaction)
    {
        $transaction->load(['item', 'branch']);
        return view('admin.inventory.stock.show', compact('transaction'));
    }

    public function edit(ItemTransaction $transaction)
    {
        $transaction->load(['item', 'branch']);
        $items = ItemMaster::all();
        $branches = Branch::active()->get();
        return view('admin.inventory.stock.edit', compact('transaction', 'items', 'branches'));
    }

    /**
     * Update the specified transaction.
     */
    public function update(Request $request, ItemTransaction $transaction)
    {
        $validated = $request->validate([
            'inventory_item_id' => 'required|exists:item_master,id',
            'branch_id' => 'required|exists:branches,id',
            'transaction_type' => 'required|in:in,out',
            'quantity' => 'required|numeric|min:0.01',
            'notes' => 'nullable|string',
        ]);

        $transaction->update($validated);

        return redirect()->route('admin.inventory.stock.index')
            ->with('success', 'Transaction updated successfully.');
    }

    /**
     * Remove the specified transaction.
     */
    public function destroy(ItemTransaction $transaction)
    {
        $transaction->delete();

        return redirect()->route('admin.inventory.stock.index')
            ->with('success', 'Transaction deleted successfully.');
    }
}


C:\Users\user\Documents\GitHub\Restaurent-Management-Sysytem\app\Http\Controllers\ItemMasterController.php


<?php

namespace App\Http\Controllers;

use App\Models\ItemCategory;
use App\Models\ItemMaster;
use Illuminate\Http\Request;
use App\Models\Branch;

class ItemMasterController extends Controller
{
    /**
     * Display a listing of items.
     */
    public function index()
    {
        $items = ItemMaster::with('category')
            ->when(request('search'), function ($query) {
                return $query->where('name', 'like', '%' . request('search') . '%')
                    ->orWhere('item_code', 'like', '%' . request('search') . '%');
            })
            ->when(request('category'), function ($query) {
                return $query->where('item_category_id', request('category'));
            })
            ->when(request()->has('status'), function ($query) {
                return $query->where('is_active', request('status'));
            })
            ->paginate(15);

        $categories = ItemCategory::active()->get();

        return view('admin.inventory.items.index', compact('items', 'categories'));
    }

    /**
     * Store a newly created item.
     */
    public function store(Request $request)
    {
        $validated = $request->validate([
            'items' => 'required|array|min:1',
            'items.*.name' => 'required|string|max:255',
            'items.*.unicode_name' => 'nullable|string|max:255',
            'items.*.item_category_id' => 'required|exists:item_categories,id',
            'items.*.item_code' => 'required|string|unique:item_master,item_code',
            'items.*.unit_of_measurement' => 'required|string|max:50',
            'items.*.reorder_level' => 'nullable|numeric|min:0',
            'items.*.is_perishable' => 'nullable|boolean',
            'items.*.shelf_life_in_days' => 'nullable|integer|min:0',
            'items.*.branch_id' => 'nullable|exists:branches,id',
            'items.*.organization_id' => 'nullable|exists:organizations,id', // This will always be 1 ~ test ~
            'items.*.buying_price' => 'required|numeric|min:0',
            'items.*.selling_price' => 'required|numeric|min:0',
            'items.*.is_menu_item' => 'nullable|boolean',
            'items.*.is_active' => 'nullable|boolean',
            'items.*.additional_notes' => 'nullable|string',
            'items.*.description' => 'nullable|string',
            'items.*.attributes' => 'nullable|json',
        ]);

        $createdItems = [];


        foreach ($validated['items'] as $itemData) {

            // Override organization_id with 1 for testing
            $itemData['organization_id'] = 1;

            $createdItems[] = ItemMaster::create([
                'name' => $itemData['name'],
                'unicode_name' => $itemData['unicode_name'] ?? null,
                'item_category_id' => $itemData['item_category_id'],
                'item_code' => $itemData['item_code'],
                'unit_of_measurement' => $itemData['unit_of_measurement'],
                'reorder_level' => $itemData['reorder_level'] ?? 0,
                'is_perishable' => $itemData['is_perishable'] ?? false,
                'shelf_life_in_days' => $itemData['shelf_life_in_days'] ?? null,
                'branch_id' => $itemData['branch_id'] ?? null,
                'organization_id' => $itemData['organization_id'], // This will now always be 1
                'buying_price' => $itemData['buying_price'],
                'selling_price' => $itemData['selling_price'],
                'is_menu_item' => $itemData['is_menu_item'] ?? false,
                'is_active' => $itemData['is_active'] ?? true,
                'additional_notes' => $itemData['additional_notes'] ?? null,
                'description' => $itemData['description'] ?? null,
                'attributes' => $itemData['attributes'] ?? null,
            ]);
        }

        return response()->json([
            'message' => 'Items created successfully',
            'data' => $createdItems
        ], 201);
    }



    /**
     * Display the specified item.
     */
    public function show($id)
    {
        $item = ItemMaster::with(['category', 'branch', 'organization'])->findOrFail($id);
        return response()->json($item);
    }

    /**
     * Update the specified item.
     */
    public function update(Request $request, $id)
    {
        $item = ItemMaster::findOrFail($id);
        $data = $request->validate([
            'name' => 'sometimes|string',
            'unicode_name' => 'nullable|string',
            'item_category_id' => 'sometimes|exists:item_categories,id',
            'item_code' => 'sometimes|string|unique:item_master,item_code,' . $id,
            'unit_of_measurement' => 'sometimes|string',
            'reorder_level' => 'nullable|integer',
            'is_perishable' => 'boolean',
            'shelf_life_in_days' => 'nullable|integer',
            'branch_id' => 'nullable|exists:branches,id',
            'organization_id' => 'sometimes|exists:organizations,id',
            'buying_price' => 'sometimes|numeric',
            'selling_price' => 'sometimes|numeric',
            'is_menu_item' => 'boolean',
            'additional_notes' => 'nullable|string',
            'description' => 'nullable|string',
            'attributes' => 'nullable|json',
        ]);

        $item->update($data);
        return redirect()->route('admin.inventory.items.index', $item->id)
            ->with('success', 'Item updated successfully');
    }


    public function getItemFormPartial($index)
    {
        return view('admin.inventory.items.partials.item-form', ['index' => $index]);
    }



    public function create()
    {
        $categories = ItemCategory::active()->get();
        $branches = Branch::where('is_active', true)->get();
        return view('admin.inventory.items.create', compact('categories', 'branches'));
    }

    public function edit($id)
    {
        $item = ItemMaster::findOrFail($id);
        $categories = ItemCategory::active()->get();
        return view('admin.inventory.items.edit', compact('item', 'categories'));
    }

    /**
     * Soft delete the specified item.
     */
    public function destroy($id)
    {
        $item = ItemMaster::findOrFail($id);
        $item->delete();

        return response()->json(['message' => 'Item deleted successfully.']);
    }
}


C:\Users\user\Documents\GitHub\Restaurent-Management-Sysytem\app\Models\ItemTransaction.php
<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class ItemTransaction extends Model
{
    protected $table = 'item_transactions';

    protected $fillable = [
        'organization_id',
        'branch_id',
        'inventory_item_id',
        'transaction_type',
        'transfer_to_branch_id',
        'receiver_user_id',
        'quantity',
        'received_quantity',
        'damaged_quantity',
        'cost_price',
        'unit_price',
        'source_id',
        'source_type',
        'created_by_user_id',
        'notes',
        'is_active',
    ];

    protected $casts = [
        'quantity' => 'decimal:2',
        'received_quantity' => 'decimal:2',
        'damaged_quantity' => 'decimal:2',
        'cost_price' => 'decimal:4',
        'unit_price' => 'decimal:4',
        'is_active' => 'boolean',
    ];

    /*
     * Relationships
     */
    public function item()
    {
        return $this->belongsTo(ItemMaster::class, 'inventory_item_id');
    }

    public function organization()
    {
        return $this->belongsTo(Organizations::class);
    }

    public function branch()
    {
        return $this->belongsTo(Branch::class);
    }

    public function receiver()
    {
        return $this->belongsTo(User::class, 'receiver_user_id');
    }

    public function createdBy()
    {
        return $this->belongsTo(User::class, 'created_by_user_id');
    }

    /*
     * Scope: Only active transactions
     */
    public function scopeActive($query)
    {
        return $query->where('is_active', true);
    }

    /*
     * Accessor: Net Stock Effect
     */
    public function getNetQuantityAttribute()
    {
        return $this->quantity - $this->damaged_quantity;
    }

    /*
     * Stock on Hand (can also be used as a static helper elsewhere)
     */
    public static function stockOnHand($itemId, $branchId = null)
    {
        $query = self::active()->where('inventory_item_id', $itemId);

        if ($branchId) {
            $query->where('branch_id', $branchId);
        }

        return $query->sum('quantity') - $query->sum('damaged_quantity');
    }
}
C:\Users\user\Documents\GitHub\Restaurent-Management-Sysytem\app\Models\ItemMaster.php
<?php

namespace App\Models;

use App\Models\Organizations;
use App\Models\ItemCategory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class ItemMaster extends Model
{
    use SoftDeletes;

    protected $table = 'item_master';

    protected $fillable = [
        'name',
        'unicode_name',
        'item_category_id',
        'item_code',
        'unit_of_measurement',
        'reorder_level',
        'is_perishable',
        'shelf_life_in_days',
        'branch_id',
        'organization_id',
        'buying_price',
        'selling_price',
        'is_menu_item',
        'additional_notes',
        'description',
        'attributes',
    ];

    protected $casts = [
        'attributes'      => 'array',
        'is_perishable'   => 'boolean',
        'is_menu_item'    => 'boolean',
        'buying_price'    => 'decimal:2',
        'selling_price'   => 'decimal:2',
    ];

    /**
     * Relationships
     */
    public function category()
    {
        return $this->belongsTo(ItemCategory::class, 'item_category_id');
    }

    public function branch()
    {
        return $this->belongsTo(Branch::class, 'branch_id');
    }

    public function organization()
    {
        return $this->belongsTo(Organizations::class, 'organization_id');
    }

    /**
     * Define the transactions relationship
     */
    public function transactions()
    {
        return $this->hasMany(ItemTransaction::class, 'inventory_item_id');
    }

    /**
     * Accessor Example: Get Ingredients if available in attributes
     */
    public function getIngredientsAttribute()
    {
        return $this->attributes['attributes']['ingredients'] ?? null;
    }

    /**
     * Accessor Example: Get Image if available in attributes
     */    
    public function getImageUrlAttribute()
    {
        if (isset($this->attributes['attributes']['img'])) {
            return asset('storage/'.$this->attributes['attributes']['img']);
        }
        return asset('https://placehold.co/200x200/png');
    }



    /**
     * Scope: Active Items Only (not soft deleted)
     */
    public function scopeActive($query)
    {
        return $query->whereNull('deleted_at');
    }

    // New scope for menu items
    public function scopeMenuItem($query)
    {
        return $query->where('is_menu_item', true);
    }

    // New scope for perishable items
    public function scopePerishable($query)
    {
        return $query->where('is_perishable', true);
    }

}



C:\Users\user\Documents\GitHub\Restaurent-Management-Sysytem\resources\views\admin\inventory\index.blade.php
{{-- Not in Use - Dashboard blade file is in use for inventory Dashboard --}}

@extends('layouts.admin')

@section('content')
<div class="py-12">
    <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
        <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
            <div class="p-6 bg-white border-b border-gray-200">
                <div class="flex justify-between items-center mb-6">
                    <h2 class="text-2xl font-semibold text-gray-800">Inventory Items</h2>
                    <a href="{{ route('admin.inventory.items.create') }}" class="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700">
                        Add New Item
                    </a>
                </div>

                <!-- Search and Filters -->
                <div class="mb-6">
                    <form action="{{ route('admin.inventory.items.index') }}" method="GET" class="flex flex-wrap gap-4">
                        <div class="flex-1 min-w-[200px]">
                            <input type="text" name="search" value="{{ request('search') }}" 
                                placeholder="Search by name or code" 
                                class="w-full px-4 py-2 border rounded-md">
                        </div>

                        <div class="w-full md:w-auto">
                            <select name="category" class="w-full px-4 py-2 border rounded-md">
                                <option value="">All Categories</option>
                                @foreach($categories as $category)
                                    <option value="{{ $category->id }}" {{ request('category') == $category->id ? 'selected' : '' }}>
                                        {{ $category->name }}
                                    </option>
                                @endforeach
                            </select>
                        </div>

                        <div class="w-full md:w-auto">
                            <button type="submit" class="px-4 py-2 bg-gray-600 text-white rounded hover:bg-gray-700">
                                Filter
                            </button>
                            <a href="{{ route('admin.inventory.items.index') }}" class="px-4 py-2 bg-gray-200 text-gray-700 rounded hover:bg-gray-300 ml-2">
                                Reset
                            </a>
                        </div>
                    </form>
                </div>

                <!-- Items Table -->
                <div class="overflow-x-auto">
                    <table class="min-w-full bg-white">
                        <thead>
                            <tr class="bg-gray-100 text-gray-600 uppercase text-sm leading-normal">
                                <th class="py-3 px-6 text-left">Code</th>
                                <th class="py-3 px-6 text-left">Name</th>
                                <th class="py-3 px-6 text-left">Category</th>
                                <th class="py-3 px-6 text-left">Unit</th>
                                <th class="py-3 px-6 text-right">Buying Price</th>
                                <th class="py-3 px-6 text-right">Selling Price</th>
                                <th class="py-3 px-6 text-center">Status</th>
                                <th class="py-3 px-6 text-center">Actions</th>
                            </tr>
                        </thead>
                        <tbody class="text-gray-600 text-sm">
                            @forelse($items as $item)
                                <tr class="border-b border-gray-200 hover:bg-gray-50">
                                    <td class="py-3 px-6 text-left">{{ $item->item_code }}</td>
                                    <td class="py-3 px-6 text-left">{{ $item->name }}</td>
                                    <td class="py-3 px-6 text-left">{{ $item->category->name ?? 'N/A' }}</td>
                                    <td class="py-3 px-6 text-left">{{ $item->unit_of_measurement }}</td>
                                    <td class="py-3 px-6 text-right">{{ number_format($item->buying_price, 2) }}</td>
                                    <td class="py-3 px-6 text-right">{{ number_format($item->selling_price, 2) }}</td>
                                    <td class="py-3 px-6 text-center">
                                        @if($item->deleted_at)
                                            <span class="bg-red-200 text-red-800 py-1 px-3 rounded-full text-xs">Deleted</span>
                                        @else
                                            <span class="bg-green-200 text-green-800 py-1 px-3 rounded-full text-xs">Active</span>
                                        @endif
                                    </td>
                                    <td class="py-3 px-6 text-center">
                                        <div class="flex item-center justify-center">
                                            <a href="{{ route('admin.inventory.items.show', $item->id) }}" class="transform hover:text-blue-500 hover:scale-110 mr-3">
                                                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="w-5 h-5">
                                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
                                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z" />
                                                </svg>
                                            </a>
                                            <a href="{{ route('admin.inventory.items.edit', $item->id) }}" class="transform hover:text-yellow-500 hover:scale-110 mr-3">
                                                <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="w-5 h-5">
                                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z" />
                                                </svg>
                                            </a>
                                            <form action="{{ route('admin.inventory.items.destroy', $item->id) }}" method="POST" class="inline">
                                                @csrf
                                                @method('DELETE')
                                                <button type="submit" class="transform hover:text-red-500 hover:scale-110" 
                                                        onclick="return confirm('Are you sure you want to delete this item?')">
                                                    <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor" class="w-5 h-5">
                                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16" />
                                                    </svg>
                                                </button>
                                            </form>
                                        </div>
                                    </td>
                                </tr>
                            @empty
                                <tr>
                                    <td colspan="8" class="py-6 text-center text-gray-500">No items found</td>
                                </tr>
                            @endforelse
                        </tbody>
                    </table>
                </div>

                <!-- Pagination -->
                <div class="mt-4">
                    {{ $items->links() }}
                </div>
            </div>
        </div>
    </div>
</div>
@endsection


web routes 
<?php

use Illuminate\Support\Facades\Route;
use Illuminate\Support\Facades\Auth;
use App\Http\Controllers\HomeController;
use App\Http\Controllers\CustomerDashboardController;
use App\Http\Controllers\ReservationController;
use App\Http\Controllers\AdminReservationController;
use App\Http\Controllers\AdminController;
use App\Http\Controllers\AdminAuthController;
use App\Http\Controllers\ItemDashboardController;
use App\Http\Controllers\ItemCategoryController;
use App\Http\Controllers\ItemMasterController;
use App\Http\Controllers\ItemTransactionController;

// Public routes
Route::get('/', function () {
    return view('welcome');
})->name('home');

// Customer dashboard: show all reservations by phone number
Route::get('/customer-dashboard', [CustomerDashboardController::class, 'showReservationsByPhone'])->name('customer.dashboard');

// Admin routes
Route::prefix('admin')->name('admin.')->group(function () {
    // Authentication (login/logout) should be outside the auth:admin middleware
    Route::get('/login', [AdminAuthController::class, 'showLoginForm'])->name('login');
    Route::post('/login', [AdminAuthController::class, 'login']);
    // New logout confirmation page and action
    Route::get('/logout', [AdminAuthController::class, 'adminLogoutPage'])->name('logout.page');
    Route::post('/logout', [AdminAuthController::class, 'adminLogout'])->name('logout.action');

    // Protected admin routes
    Route::middleware('auth:admin')->group(function () {
        Route::get('/dashboard', [AdminController::class, 'dashboard'])->name('dashboard');
        Route::resource('reservations', AdminReservationController::class);

        // Inventory routes
        Route::prefix('inventory')->name('inventory.')->group(function () {
            // Dashboard
            // Route::get('/', [ItemMasterController::class, 'index'])->name('index');
            Route::get('/', [ItemDashboardController::class, 'index'])->name('index');
            Route::get('/dashboard', [ItemDashboardController::class, 'index'])->name('dashboard');

            // Inventory Item Routes
            Route::prefix('items')->name('items.')->group(function () {
                Route::get('/', [ItemMasterController::class, 'index'])->name('index');
                Route::get('/create', [ItemMasterController::class, 'create'])->name('create');
                Route::post('/', [ItemMasterController::class, 'store'])->name('store');
                Route::get('/{item}', [ItemMasterController::class, 'show'])->whereNumber('item')->name('show');
                Route::get('/{item}/edit', [ItemMasterController::class, 'edit'])->name('edit');
                Route::put('/{item}', [ItemMasterController::class, 'update'])->name('update');
                Route::delete('/{item}', [ItemMasterController::class, 'destroy'])->name('destroy');
                Route::get('/create-template/{index}/', [ItemMasterController::class, 'getItemFormPartial'])->name('form-partial');
            });

            Route::prefix('stock')->name('stock.')->group(function () {
                Route::get('/', [ItemTransactionController::class, 'index'])->name('index');
                Route::get('/create', [ItemTransactionController::class, 'create'])->name('create');
                Route::post('/', [ItemTransactionController::class, 'store'])->name('store');
                // Route::get('/transactions', [ItemTransactionController::class, 'transactions'])->name('transactions');
                Route::get('/{transaction}', [ItemTransactionController::class, 'show'])->whereNumber('transaction')->name('show');
                Route::get('/{transaction}/edit', [ItemTransactionController::class, 'edit'])->name('edit');
                Route::put('/{transaction}', [ItemTransactionController::class, 'update'])->name('update');
                Route::delete('/{transaction}', [ItemTransactionController::class, 'destroy'])->name('destroy');

                Route::prefix('transactions')->name('transactions.')->group(function () {
                    Route::get('/', [ItemTransactionController::class, 'transactions'])->name('index');
                });
            });

            Route::resource('categories', ItemCategoryController::class);
        });
    });
});

// Reservation routes
Route::prefix('reservations')->name('reservations.')->group(function () {
    // Main reservation routes
    Route::get('/create', [ReservationController::class, 'create'])->name('create');
    Route::post('/store', [ReservationController::class, 'store'])->name('store');
    Route::get('/edit', [ReservationController::class, 'edit'])->name('edit');
    Route::get('/review', [ReservationController::class, 'review'])->name('review.get');
    Route::post('/review', [ReservationController::class, 'review'])->name('review');
    Route::get('/cancellation-success', [ReservationController::class, 'cancellationSuccess'])->name('cancellation-success');
    // Parameterized reservation routes
    Route::get('/{reservation}/summary', [ReservationController::class, 'summary'])->name('summary')->where('reservation', '[0-9]+');
    Route::get('/{reservation}/cancel', [ReservationController::class, 'cancel'])->name('cancel')->where('reservation', '[0-9]+');
    Route::get('/{reservation}', [ReservationController::class, 'show'])->name('show')->where('reservation', '[0-9]+');
    Route::post('/{reservation}/confirm', [ReservationController::class, 'confirm'])->name('confirm');
});

C:\Users\user\Documents\GitHub\Restaurent-Management-Sysytem\resources\views\admin\inventory\stock\index.blade.php
@extends('layouts.main')
@section('content')
<div class="max-w-7xl mx-auto bg-white dark:bg-gray-800 rounded-lg shadow-md p-6">
    <!-- Header with Stats -->
    <div class="mb-8">
        <div class="flex justify-between items-center mb-6">
            <div>
                <h2 class="text-2xl font-bold text-gray-900 dark:text-white">Inventory Dashboard</h2>
                <p class="text-sm text-gray-500 dark:text-gray-400">Real-time stock levels across branches</p>
            </div>
            <div class="flex space-x-3">
                <a href="{{ route('admin.inventory.stock.create') }}" 
                   class="px-4 py-2 bg-green-600 hover:bg-green-700 text-white rounded-lg flex items-center">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" viewBox="0 0 20 20" fill="currentColor">
                        <path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd" />
                    </svg>
                    Add Stock
                </a>
                <a href="{{ route('admin.inventory.stock.transactions.index') }}" 
                   class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg flex items-center">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" viewBox="0 0 20 20" fill="currentColor">
                        <path d="M4 4a2 2 0 00-2 2v1h16V6a2 2 0 00-2-2H4z" />
                        <path fill-rule="evenodd" d="M18 9H2v5a2 2 0 002 2h12a2 2 0 002-2V9zM4 13a1 1 0 011-1h1a1 1 0 110 2H5a1 1 0 01-1-1zm5-1a1 1 0 100 2h1a1 1 0 100-2H9z" clip-rule="evenodd" />
                    </svg>
                    View History
                </a>
            </div>
        </div>

        <!-- Stats Cards -->
        <div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
            <div class="bg-blue-50 dark:bg-blue-900/30 p-4 rounded-lg border border-blue-100 dark:border-blue-900">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-sm font-medium text-blue-800 dark:text-blue-200">Total Items</p>
                        <p class="text-2xl font-bold text-blue-900 dark:text-white">{{ $itemsCount ?? 0 }}</p>
                    </div>
                    <div class="p-3 rounded-full bg-blue-100 dark:bg-blue-800/50 text-blue-600 dark:text-blue-300">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" />
                        </svg>
                    </div>
                </div>
            </div>
            
            <div class="bg-green-50 dark:bg-green-900/30 p-4 rounded-lg border border-green-100 dark:border-green-900">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-sm font-medium text-green-800 dark:text-green-200">In Stock</p>
                        <p class="text-2xl font-bold text-green-900 dark:text-white">{{ $inStockCount ?? 0 }}</p>
                    </div>
                    <div class="p-3 rounded-full bg-green-100 dark:bg-green-800/50 text-green-600 dark:text-green-300">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
                        </svg>
                    </div>
                </div>
            </div>
            
            <div class="bg-yellow-50 dark:bg-yellow-900/30 p-4 rounded-lg border border-yellow-100 dark:border-yellow-900">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-sm font-medium text-yellow-800 dark:text-yellow-200">Low Stock</p>
                        <p class="text-2xl font-bold text-yellow-900 dark:text-white">{{ $nearReorderCount ?? 0 }}</p>
                    </div>
                    <div class="p-3 rounded-full bg-yellow-100 dark:bg-yellow-800/50 text-yellow-600 dark:text-yellow-300">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" />
                        </svg>
                    </div>
                </div>
            </div>
            
            <div class="bg-red-50 dark:bg-red-900/30 p-4 rounded-lg border border-red-100 dark:border-red-900">
                <div class="flex items-center justify-between">
                    <div>
                        <p class="text-sm font-medium text-red-800 dark:text-red-200">Out of Stock</p>
                        <p class="text-2xl font-bold text-red-900 dark:text-white">{{ $outOfStockCount ?? 0 }}</p>
                    </div>
                    <div class="p-3 rounded-full bg-red-100 dark:bg-red-800/50 text-red-600 dark:text-red-300">
                        <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" />
                        </svg>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Filters -->
    <div class="mb-6 bg-gray-50 dark:bg-gray-700/50 p-4 rounded-lg">
        <form method="GET" action="{{ route('admin.inventory.stock.index') }}" class="grid grid-cols-1 md:grid-cols-4 gap-4">
            <!-- Search -->
            <div>
                <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Search</label>
                <input type="text" name="search" value="{{ request('search') }}"
                       placeholder="Item name or code"
                       class="w-full rounded-lg border-gray-300 shadow-sm dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-blue-500 focus:ring-blue-500">
            </div>
            
            <!-- Branch Filter -->
            <div>
                <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Branch</label>
                <select name="branch_id" class="w-full rounded-lg border-gray-300 shadow-sm dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-blue-500 focus:ring-blue-500">
                    <option value="">All Branches</option>
                    @foreach($branches as $branch)
                        <option value="{{ $branch->id }}" {{ request('branch_id') == $branch->id ? 'selected' : '' }}>
                            {{ $branch->name }}
                        </option>
                    @endforeach
                </select>
            </div>
            
            <!-- Status Filter -->
            <div>
                <label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1">Status</label>
                <select name="status" class="w-full rounded-lg border-gray-300 shadow-sm dark:bg-gray-700 dark:text-white dark:border-gray-600 focus:border-blue-500 focus:ring-blue-500">
                    <option value="">All Statuses</option>
                    <option value="in_stock" {{ request('status') == 'in_stock' ? 'selected' : '' }}>In Stock</option>
                    <option value="low_stock" {{ request('status') == 'low_stock' ? 'selected' : '' }}>Low Stock</option>
                    <option value="out_of_stock" {{ request('status') == 'out_of_stock' ? 'selected' : '' }}>Out of Stock</option>
                </select>
            </div>
            
            <!-- Filter Buttons -->
            <div class="flex items-end space-x-2">
                <button type="submit" class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg flex items-center justify-center w-full">
                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-1" viewBox="0 0 20 20" fill="currentColor">
                        <path fill-rule="evenodd" d="M3 3a1 1 0 011-1h12a1 1 0 011 1v3a1 1 0 01-.293.707L12 11.414V15a1 1 0 01-.293.707l-2 2A1 1 0 018 17v-5.586L3.293 6.707A1 1 0 013 6V3z" clip-rule="evenodd" />
                    </svg>
                    Filter
                </button>
                @if(request()->anyFilled(['search', 'branch_id', 'status']))
                    <a href="{{ route('admin.inventory.stock.index') }}" class="px-4 py-2 bg-gray-500 hover:bg-gray-600 text-white rounded-lg flex items-center justify-center w-full">
                        Clear
                    </a>
                @endif
            </div>
        </form>
    </div>

    <!-- Stock Levels Table -->
    <div class="overflow-x-auto rounded-lg border border-gray-200 dark:border-gray-700">
        <table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
            <thead class="bg-gray-50 dark:bg-gray-700">
                <tr>
                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">
                        Item Details
                    </th>
                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">
                        Branch
                    </th>
                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">
                        Stock Level
                    </th>
                    <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">
                        Status
                    </th>
                    <th scope="col" class="px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider">
                        Actions
                    </th>
                </tr>
            </thead>
            <tbody class="bg-white divide-y divide-gray-200 dark:divide-gray-700 dark:bg-gray-800">
                @forelse($stocks as $stock)
                    <tr class="hover:bg-gray-50 dark:hover:bg-gray-700/50">
                        <!-- Item Details -->
                        <td class="px-6 py-4 whitespace-nowrap">
                            <div class="flex items-center">
                                <div class="flex-shrink-0 h-10 w-10 bg-gray-200 dark:bg-gray-600 rounded-md flex items-center justify-center">
                                    <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 text-gray-600 dark:text-gray-300" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" />
                                    </svg>
                                </div>
                                <div class="ml-4">
                                    <div class="text-sm font-medium text-gray-900 dark:text-white">
                                        {{ $stock['item']->name }}
                                    </div>
                                    <div class="text-sm text-gray-500 dark:text-gray-400">
                                        {{ $stock['item']->item_code }} • {{ optional($stock['item']->category)->name ?? 'Uncategorized' }}
                                    </div>
                                </div>
                            </div>
                        </td>
                        
                        <!-- Branch -->
                        <td class="px-6 py-4 whitespace-nowrap">
                            <div class="text-sm text-gray-900 dark:text-white">{{ $stock['branch']->name }}</div>
                        </td>
                        
                        <!-- Stock Level -->
                        <td class="px-6 py-4 whitespace-nowrap">
                            <div class="text-sm text-gray-900 dark:text-white">
                                <span class="font-medium">{{ $stock['current_stock'] }}</span> 
                                <span class="text-gray-500 dark:text-gray-400">/ {{ $stock['reorder_level'] }}</span>
                                <span class="text-xs text-gray-500 dark:text-gray-400 ml-1">{{ $stock['item']->unit_of_measurement }}</span>
                            </div>
                        
                            <div class="w-full bg-gray-200 rounded-full h-1.5 dark:bg-gray-700 mt-1">
                                @php
                                    $percentage = ($stock['reorder_level'] > 0) 
                                        ? min(100, ($stock['current_stock'] / $stock['reorder_level']) * 100) 
                                        : 0;
                            
                                    $color = $stock['status'] === 'low_stock' ? 'bg-yellow-500' : 'bg-green-500';
                                @endphp
                                <div class="h-1.5 rounded-full {{ $color }}" style="width: {{ $percentage }}%"></div>
                            </div>
                        </td>
                        
                        <!-- Status -->
                        <td class="px-6 py-4 whitespace-nowrap">
                            @if($stock['status'] === 'low_stock')
                                <span class="px-2.5 py-0.5 inline-flex items-center text-xs font-medium rounded-full bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100">
                                    <svg class="-ml-0.5 mr-1.5 h-2 w-2 text-yellow-500 dark:text-yellow-300" fill="currentColor" viewBox="0 0 8 8">
                                        <circle cx="4" cy="4" r="3" />
                                    </svg>
                                    Low Stock
                                </span>
                            @else
                                <span class="px-2.5 py-0.5 inline-flex items-center text-xs font-medium rounded-full bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100">
                                    <svg class="-ml-0.5 mr-1.5 h-2 w-2 text-green-500 dark:text-green-300" fill="currentColor" viewBox="0 0 8 8">
                                        <circle cx="4" cy="4" r="3" />
                                    </svg>
                                    In Stock
                                </span>
                            @endif
                        </td>
                        
                        <!-- Actions -->
                        <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
                            <div class="flex justify-end space-x-2">
                                <a href="{{ route('admin.inventory.stock.create', ['item_id' => $stock['item']->id, 'branch_id' => $stock['branch']->id]) }}" 
                                   class="text-blue-600 hover:text-blue-900 dark:text-blue-400 dark:hover:text-blue-300 px-2 py-1 rounded hover:bg-blue-50 dark:hover:bg-blue-900/30"
                                   title="Add Transaction">
                                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                                        <path fill-rule="evenodd" d="M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z" clip-rule="evenodd" />
                                    </svg>
                                </a>
                                <a href="{{ route('admin.inventory.stock.transactions.index', ['item_id' => $stock['item']->id, 'branch_id' => $stock['branch']->id]) }}" 
                                   class="text-purple-600 hover:text-purple-900 dark:text-purple-400 dark:hover:text-purple-300 px-2 py-1 rounded hover:bg-purple-50 dark:hover:bg-purple-900/30"
                                   title="View History">
                                    <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor">
                                        <path d="M4 4a2 2 0 00-2 2v1h16V6a2 2 0 00-2-2H4z" />
                                        <path fill-rule="evenodd" d="M18 9H2v5a2 2 0 002 2h12a2 2 0 002-2V9zM4 13a1 1 0 011-1h1a1 1 0 110 2H5a1 1 0 01-1-1zm5-1a1 1 0 100 2h1a1 1 0 100-2H9z" clip-rule="evenodd" />
                                    </svg>
                                </a>
                            </div>
                        </td>
                    </tr>
                @empty
                    <tr>
                        <td colspan="5" class="px-6 py-4 text-center text-sm text-gray-500 dark:text-gray-400">
                            No stock items found matching your criteria.
                        </td>
                    </tr>
                @endforelse
            </tbody>
        </table>
    </div>

    <!-- Pagination -->
    <div class="mt-4">
        {{ $stocks->links() }}
    </div>
</div>
@endsection

create the add transactions Form - (create.blade.php) this is laravale the given gintrollers and models and etc