@extends('layouts.Layout')

@section('content')
<div class="col-md-12">
  <div class="card">
      <div class="header">
          <h4> Upload Pengumuman</h4>
          <p class="category"></p>
      </div>
      <div class="content table-responsive table-full-width" id="table">
        <div class="col-md-6">
        {!!Form::open(array('route'=>'upload.create','method'=>'POST', 'files'=>true )) !!}
        {!!Form::file('images[]', array('multiple'=>true , 'class'=> 'btn btn-default btn-file' , 'hidden')) !!}
          <p>{!!$errors->first('images')!!}</p>
          @if(Session::has('error'))
            <p>{!! Session::get('error') !!}</p>
          @endif
        <div class="row">
          <div class="col-md-5">
            <div class="form-group @if($errors->has('judul')) has-error @endif">
              <label>Judul</label>
                <input id="text" type="text" class="form-control border-input" value="{{old('judul')}}" name="judul">
                  <span id="helpBlock2" class="help-block">{{$errors->first('judul')}}</span>
            </div>
          </div>
          <div class="col-md-5">
            <div class="form-group @if($errors->has('jenis')) has-error @endif">
              <label>Jenis</label>
                <select type="textarea" class="form-control border-input" value="{{old('jenis')}}" name="jenis">
                  <option>Pengumuman</option>
                  <option>Soal</option>
                </select>
                  <span id="helpBlock2" class="help-block">{{$errors->first('jenis')}}</span>
            </div>
          </div>
          </div>
          <div class="row">
          <div class="col-lg-20">
            <div class="form-group @if($errors->has('keterangan')) has-error @endif">
              <label>Keterangan</label>
                <textarea id="textarea" type="textarea" class="form-control border-input" value="{{old('keterangan')}}" name="keterangan"></textarea>
                  <span id="helpBlock2" class="help-block">{{$errors->first('keterangan')}}</span>
            </div>
          </div>
        </div>
        <div class="form-group">
          <button type="submit" class="btn btn-info"><span class="glyphicon glyphicon-upload"></span>Unggah</button>
        </div>


        {!! Form::close() !!}
      </div>

    <table class="table table-striped">
      <tr>
        <th>No.</th>
        <th>Jenis</th>
        <th>File</th>
        <th>Keterangan</th>
        <th>Actions</th>
      </tr>
        <?php $no=1; ?>
        @foreach($pengumuman as $upload)
      <tr>
        <td>{{$no++}}</td>
        <td>{{$upload->jenis}}</td>
        <td>{{$upload->original_filename}}</td>
        <td>{{$upload->keterangan}}</td>
        <td>
          <form class="" action="{{route('upload.destroy', $upload->id)}}" method="post">
          <input class="w3-btn" type="hidden" name="_method" value="delete">
          <input class="w3-btn" type="hidden" name="_token" value="{{ csrf_token() }}">
          <a href="uploads/{{$upload->original_filename}}" download="{{$upload->filename}}">
            <button type="button" class="btn btn-primary"><i class="glyphicon glyphicon-download"> Download</i></button> 
          </a>
            <button class="delete-modal btn btn-danger" onclick="return confirm('Are you sure to delete this data');"  ><span class="glyphicon glyphicon-trash"></span> Hapus</button>
          </form>
        </td>
      </tr>
        @endforeach
    </table>
    </div>
  </div>
</div>

    </div>
 @endsection
