@extends('layouts.app')

@section('content')
<div class="card">
    <div class="card-body">
    <h4 class="card-title">Create Gallery</h4>
    <h6 class="card-subtitle"></h6>
      <div class="x_content">
        <form id="demo-form2" action="{{ url('/admin/addgallery') }}" method="post" data-parsley-validate class="form-horizontal form-label-left">
          {{ csrf_field() }}
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Video Code <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="text" id="first-name" name="title" required="required" class="form-control col-md-7 col-xs-12" value="">
              @if ($errors->has('title'))
                  <span class="help-block">
                      <strong>{{ $errors->first('title') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Content <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <textarea name="content" required="required" class="form-control col-md-7 col-xs-12"></textarea>
              @if ($errors->has('content'))
                  <span class="help-block">
                      <strong>{{ $errors->first('content') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="form-group">
            <label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Active <span class="required">*</span>
            </label>
            <div class="col-md-6 col-sm-6 col-xs-12">
              <input type="checkbox" name="active" class="" checked="checked" />
              @if ($errors->has('active'))
                  <span class="help-block">
                      <strong>{{ $errors->first('active') }}</strong>
                  </span>
              @endif
            </div>
          </div>
          <div class="ln_solid"></div>
          <div class="form-group">
            <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
              <button type="submit" class="btn btn-success">Submit</button>
            </div>
          </div>
        </form>
      </div>
    </div>
  </div>
<div class="card">
  <div class="card-body">
    <h4 class="card-title">Gallery History</h4>
      <div class="x_content">
        <table id="datatable-fixed-header" class="table table-striped table-bordered">
          <thead>
            <tr>
              <th>Title</th>
              <th>Content</th>
              <th>Active</th>
              <th>Created at</th>
              <th>Action</th>
            </tr>
          </thead>


          <tbody>
          @foreach ($published_gallery as $gallery)
            <tr>
              <td>{{ $gallery->title }}</td>
              <td>{{ $gallery->content }}</td>
              <td>{{ $gallery->active }}</td>
              <td>{{ $gallery->created_at }}</td>
              <td>
                <a type="button" class="btn btn-success" href="{{ url('/admin/addgallery'.'/'.$gallery->id) }}">Edit</a>
                <a type="button" class="btn btn-danger" href="{{ route('admin.gallery.destroy', ['id'=>$gallery->id]) }}">Delete</a>
              </td>
            </tr>
          @endforeach
          </tbody>
        </table>
      </div>
    </div>
  </div>
<script>
  $(document).ready(function() {
   $('#datatable-fixed-header').DataTable({
      fixedHeader: true
    });
  });
</script>
@endsection
