{!! Form::model($model, [
	'route' => $model->exists ? ['blog.update', $model->id] : 'blog.store',
	'method' => $model->exists ? 'PUT' : 'POST',
	'enctype' => 'multipart/form-data',
  'id' => 'formSubmit'
]) !!}
<input type="hidden" name="_token" id="_token" value="{{csrf_token()}}">
<div class="form-group">
	<label for="" class="label-control">Title</label>
	{!! Form::text('title', null, ['class' => 'form-control', 'id' => 'title', 'placeholder' => 'Inputkan title blog...']) !!}
</div>

<div class="form-group">
	<label for="" class="label-control">Content</label>
	{!! Form::textarea('content', null, ['class' => 'form-control textarea', 'id' => 'content', 'placeholder' => 'Isi konten disini...']) !!}
</div>

@if($model->exists)
<div class="form-group">
	<label for="" class="label-control">Updated Date</label>
	{!! Form::text('updated_at', $model->updated_at != NULL ? $model->updated_at : NULL, ['class' => 'form-control textarea', 'id' => 'updated_at', 'placeholder' => date('Y-m-d H:i:s')]) !!}
</div>
@endif

{!! Form::close() !!}

@if($model->exists)
<a href="#" onclick="document.getElementById('picture-{{$model->id}}').click()" title="Klik untuk ganti gambar"><img src="<?php if($model->picture != NULL){ echo url('assets/files/blog').'/'.$model->picture; }else{ echo url('assets/frontend/img/no-picture.png'); } ?>" width="100px"></a>
<br>
@if($model->picture != NULL)
<button class="btn btn-xs btn-warning" id="hapusGambar" data-id="{{$model->id}}"><i class="fa fa-close"> Hapus Gambar</i></button>
@endif
<p style="font-size: 10px; color:red;">Size gambar max: 500kb!</p>
<input type="hidden" name="id" value="{{ $model->id }}">
<input type="hidden" name="_token" id="_token" value="{{csrf_token()}}">
<input style="display: none;" type="file" name="picture" id="picture-{{$model->id}}" data-id="{{$model->id}}" class="uploadfoto" accept="image/*">
@endif

<script>
	$(function () {
    // Replace the <textarea id="editor1"> with a CKEditor
    // instance, using default configuration.
    CKEDITOR.replace('content')
    //bootstrap WYSIHTML5 - text editor
    // $('.textarea').wysihtml5()
  })
</script>
