@extends('layouts.app')

@section('content')
    <div class="container text-center">
        <a href="{{ url('orders/create') }}" class="btn btn-success">Create</a>
        <table class="table">
            <thead>
                <tr>
                    <th scope="col">#</th>
                    <th scope="col">Company</th>
                    <th scope="col">Name</th>
                    <th scope="col">Phone</th>
                    <th scope="col">Description</th>
                    <th scope="col">Email Date</th>
                    <th scope="col">Due Date</th>
                    <th scope="col">Action</th>
                </tr>
            </thead>
            <tbody>
                @foreach ($orders as $order)
                    <tr>
                        <th scope="row">{{ $order->id }}</th>
                        <td>{{ $order->company }}</td>
                        <td>{{ $order->name }}</td>
                        <td>{{ $order->phone }}</td>
                        <td>{{ $order->description }}</td>
                        <td>{{ $order->created_at }}</td>
                        <td>{{ $order->due_date }}</td>
                        <td>
                            <form action="/orders/{{ $order->id }}" method="POST">
                                @method('DELETE')
                                @csrf
                                <a href="/orders/{{ $order->id }}" class="btn btn-success">View</a>
                                <a href="/orders/{{ $order->id }}/edit" class="btn btn-success">Edit</a>
                                <button type="submit" class="btn btn-danger">Delete</button>
                            </form>
                        </td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    </div>
@endsection
