<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title></title>
  <link
    href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css"
    rel="stylesheet"
  >
</head>

<body>
  <div class="container mt-2">
    <div class="row">
      <div class="col-lg-12 margin-tb">
        <div class="pull-left">
          <h2>heloworld CRUD</h2>
        </div>
        <div class="pull-right mb-2">
          <a
            class="btn btn-success"
            href="{{ route('companies.create') }}"
          >
            Create Company</a>
        </div>
      </div>
    </div>
    @if ($message = Session::get('success'))
      <div class="alert alert-success">
        <p>{{ $message }}</p>
      </div>
    @endif
    <table class="table-bordered table">
      <thead>
        <tr>
          <th>S.No</th>
          <th>Company Name</th>
          <th>Company Email</th>
          <th>Company Address</th>
          <th width="280px">Action</th>
        </tr>
      </thead>
      <tbody>
        @foreach ($companies as $company)
          <tr>
            <td>{{ $company->id }}</td>
            <td>{{ $company->name }}</td>
            <td>{{ $company->email }}</td>
            <td>{{ $company->address }}</td>
            <td>
              <form
                action="{{ route('companies.destroy', $company->id) }}"
                method="POST"
              >
                <a
                  class="btn btn-primary"
                  href="{{ route('companies.edit', $company->id) }}"
                >Edit</a>
                @csrf
                @method('DELETE')
                <button
                  class="btn btn-danger"
                  type="submit"
                >Delete</button>
              </form>
            </td>
          </tr>
        @endforeach
      </tbody>
    </table>
    {!! $companies->links() !!}
  </div>
</body>

</html>
