<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Models\TrackingUpdate;
use App\Models\Shipment;
use Illuminate\Http\Request;

class TrackUpdateController extends Controller
{
    public function index(Shipment $shipment)
    {
        $updates = $shipment->trackingUpdates()->orderBy('created_at', 'desc')->get();
        return view('admin.tracking-updates.index', compact('shipment', 'updates'));
    }

    public function destroy(Shipment $shipment, TrackingUpdate $update)
    {
        $update->delete();
        return back()->with('success', 'Tracking update deleted successfully.');
    }
}