<?php

namespace App\Http\Controllers;

use App\Models\ProductReturn;
use App\Models\Sale;
use App\Models\Customer;
use Illuminate\Http\Request;

class ProductReturnController extends Controller
{
    public function index()
    {
        $returns = ProductReturn::with(['sale', 'customer'])
            ->orderBy('created_at', 'desc')
            ->paginate(20);
        
        return view('returns.index', compact('returns'));
    }

    public function create()
    {
        $sales = Sale::with('customer')
            ->where('status', 'completed')
            ->orderBy('created_at', 'desc')
            ->limit(100)
            ->get();
        
        return view('returns.create', compact('sales'));
    }

    public function store(Request $request)
    {
        // Your store logic here
    }

    public function show(ProductReturn $return)
    {
        $return->load(['sale.customer', 'items.product', 'approvedBy', 'processedBy']);
        return view('returns.show', compact('return'));
    }

    public function edit(ProductReturn $return)
    {
        // Your edit logic here
    }

    public function update(Request $request, ProductReturn $return)
    {
        // Your update logic here
    }

    public function destroy(ProductReturn $return)
    {
        // Your delete logic here
    }

    public function process(Request $request, ProductReturn $return)
    {
        // Process return logic here
    }
}