@extends('admin.layouts.app')
@section('title', 'Updates')
@section('content')
<div class="action-bar">
    <span>{{ $updates->total() }} updates</span>
    <a href="{{ route('admin.updates.create') }}" class="btn btn-primary">+ New Update</a>
</div>
<div class="card">
    <table>
        <tr><th>Image</th><th>Title</th><th>Price</th><th>Order</th><th>Active</th><th>Actions</th></tr>
        @foreach($updates as $update)
        <tr>
            <td>@if($update->image)<img src="{{ asset('storage/'.$update->image) }}" class="product-img" alt="">@else—@endif</td>
            <td><strong>{{ $update->title }}</strong></td>
            <td>{{ $update->price > 0 ? '$'.number_format($update->price,2) : '—' }}</td>
            <td>{{ $update->order }}</td>
            <td>{!! $update->is_active ? '<span style="color:#6fcf97">Yes</span>' : '<span style="color:#e74c3c">No</span>' !!}</td>
            <td class="inline-flex">
                <a href="{{ route('admin.updates.edit', $update) }}" class="btn btn-primary btn-sm">Edit</a>
                <form action="{{ route('admin.updates.destroy', $update) }}" method="POST" onsubmit="return confirm('Delete?')">
                    @csrf @method('DELETE')
                    <button type="submit" class="btn btn-danger btn-sm">Delete</button>
                </form>
            </td>
        </tr>
        @endforeach
    </table>
    <div class="pagination">{{ $updates->links() }}</div>
</div>
@endsection
