@extends('backend/layouts/layout')
@section('product_select', 'active')
@section('container')
<!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0">Products</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Home</a></li>
              <li class="breadcrumb-item">Products</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
      @if(session()->has('msg'))
          <div class="alert alert-success" role="alert">
            {{session('msg')}}
          </div>
        @endif
        <!-- Small boxes (Stat box) -->
        <div class="row">
        <div class="col-12">


<div class="card">
  <div class="card-header">
    <!-- <h3 class="card-title">DataTable with default features</h3> -->
    <a href="{{route('product_insert')}}" class="btn btn-primary float-right">Add Product</a>
  </div>
  <!-- /.card-header -->
  <div class="card-body">
    <table id="example1" class="table table-bordered table-striped">
    <thead>
        <tr>
            <th>Sl no</th>
            <th>Title</th>
            <th>Description</th>
            <th>Image</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
      @foreach($products as $list)
        <tr>
            <td>{{$list->id}}</td>
            <td>{{$list->title}}</td>
            <td>
              @php
                echo substr($list->descr, 0, 100)."...";
              @endphp
            </td>
            <td>
              <img src="{{asset('storage/media/'.$list->image)}}" height="70px" width="70px" alt="">
            </td>
            <td>
                <a href="{{route('product_edit')}}/{{$list->id}}">
                <i class="fa-regular fa-edit" style="color:green;"></i></a>&nbsp;
                <a onclick="return cnf()" href="{{route('product_delete')}}/{{$list->id}}">
                <i class="fa-regular fa-trash-can" style="color:red;"></i></a>
            </td>
        </tr>
      @endforeach
    </tbody>
    </table>
  </div>
  <!-- /.card-body -->
</div>
<!-- /.card -->
</div>
<!-- /.col -->
        </div>
        <!-- /.row -->
        <!-- Main row -->
       
        <!-- /.row (main row) -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->
  @endsection