@extends('admin.layouts.admin')
@section('content')
    <div class="pagetitle">
      <h1>Dashboard</h1>
      <nav>
        <ol class="breadcrumb">
          <li class="breadcrumb-item"><a href="#">Home</a></li>
          <li class="breadcrumb-item">Dashboard</li>
          <li class="breadcrumb-item active">Plans</li>
        </ol>
      </nav>
    </div><!-- End Page Title -->

    <section class="section dashboard">
        <div class="row">

            <!-- Left side columns -->
            <div class="col-lg-12">


                <div class="card">
                    <div class="card-body">
                        <h5 class="card-title">Plans Management
                            <a href="{{ route('admin.plans.create') }}" class="btn btn-success float-end"><i class="ri ri-add-fill"></i> Create New</a>
                        </h5>
                        {{-- <p>Personal accounts list where admin can edit, update and delete their records.</p> --}}

                        @if(session('success'))
                            <div class="alert alert-success">{{ session('success') }}</div>
                        @endif

                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>ID</th>
                                    <th>Title</th>
                                    <th>Days</th>
                                    <th>Price</th>
                                    <th>Status</th>
                                    <th>Trial Days</th>
                                    <th>Plan Type</th>
                                    <th>Actions</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($plans as $plan)
                                    <tr>
                                        <td>{{ $plan->id }}</td>
                                        <td>{{ $plan->title }}</td>
                                        <td>{{ $plan->days }}</td>
                                        <td>{{ $plan->price }}</td>
                                        <td>{{ $plan->status ? 'Active' : 'Inactive' }}</td>
                                        <td>{{ $plan->trial_days }}</td>
                                        <td>{{ ucfirst($plan->plan_type) }}</td>
                                        <td>
                                            <a href="{{ route('admin.plans.show', $plan->id) }}" class="btn btn-info btn-sm">View</a>
                                            <a href="{{ route('admin.plans.edit', $plan->id) }}" class="btn btn-warning btn-sm">Edit</a>
                                            <form action="{{ route('admin.plans.destroy', $plan->id) }}" method="POST" style="display:inline;">
                                                @csrf
                                                @method('DELETE')
                                                <button type="submit" class="btn btn-danger btn-sm">Delete</button>
                                            </form>
                                        </td>
                                    </tr>
                                @endforeach
                            </tbody>
                        </table>

                    </div>
                </div>

            </div><!-- End Left side columns -->

        </div>
    </section>

@endsection
