Commit 264d6e8b by Aan Choesni Herlingga

crud post without image

parent 12af00a4
<?php
namespace App\Http\Controllers\Webprofile\Backend;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Models\Webprofile\Categories;
use App\Repositories\Webprofile\CategoryRepository;
use App\Repositories\Webprofile\PostRepository;
class PostController extends Controller
{
private $repo;
public function __construct(PostRepository $repo)
{
$this->repo = $repo;
}
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
if ($request->ajax()) {
$data = $this->repo->get();
return $this->repo->datatable($data);
}
return view('webprofile.backend.posts.index')->withTitle(trans('feature.post'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$categories = Categories::pluck('name', 'id');
$data = [
'categories' => $categories,
];
return view('webprofile.backend.posts.create', $data)->withTitle(trans('feature.create_post'));
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$data = $request->except('_token');
array_key_exists('post_status', $data) ? $data['post_status'] = 1 : $data['post_status'] = 0;
array_key_exists('cover_status', $data) ? $data['cover_status'] = 1 : $data['cover_status'] = 0;
$this->repo->store($data);
return redirect()->route('posts.index');
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
$data = $this->repo->findId($id);
$categories = Categories::pluck('name', 'id');
$data = [
'data' => $data,
'categories' => $categories,
];
return view('webprofile.backend.posts.edit', $data)->withTitle(trans('feature.create_post'));
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$data = $request->except(['_token', 'id']);
array_key_exists('post_status', $data) ? $data['post_status'] = 1 : $data['post_status'] = 0;
array_key_exists('cover_status', $data) ? $data['cover_status'] = 1 : $data['cover_status'] = 0;
$post = $this->repo->findId($id);
$edit = $this->repo->update($data, $post);
return redirect()->route('posts.index');
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
$data = $this->repo->findId($id);
$this->repo->destroy($data);
return response()->json(['done']);
}
}
......@@ -15,7 +15,7 @@ class Posts extends Model
protected $guarded = [];
public function kategori()
public function rCategory()
{
return $this->belongsTo(Categories::class, 'categories', 'id');
}
......
......@@ -30,14 +30,26 @@ class PostRepository extends Repository
->get();
}
/**
* Custom Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store($request)
{
$request['userid_created'] = auth()->user()->id;
return $this->model->create($request);
}
public function datatable($data)
{
return DataTables::of($data)
->addIndexColumn()
->addColumn('action', function ($row) {
$btn = '<a href="javascript:void(0)" data-toggle="tooltip" data-id="' . $row->id . '" data-original-title="Edit" class="edit btn btn-warning btn-round btn-sm edit">Edit</a>';
$btn = '<a href="' . url('/webprofile/posts/' . $row->id . '/edit') . '" data-toggle="tooltip" data-id="' . $row->id . '" data-original-title="' . trans('label.edit') . '" class="edit btn btn-warning btn-round btn-sm edit">' . trans('label.edit') . '</a>';
$btn = $btn . ' <a href="javascript:void(0)" data-toggle="tooltip" data-id="' . $row->id . '" data-original-title="Delete" class="btn btn-danger btn-round btn-sm delete">Delete</a>';
$btn = $btn . ' <a href="javascript:void(0)" data-toggle="tooltip" data-id="' . $row->id . '" data-original-title="' . trans('label.delete') . '" class="btn btn-danger btn-round btn-sm delete">' . trans('label.delete') . '</a>';
$btn = $btn . '<br>';
......@@ -51,7 +63,33 @@ class PostRepository extends Repository
}
return $str;
})
->rawColumns(['action', 'status'])
->addColumn('category', function ($row) {
$str = $row->rCategory->name;
return $str;
})
->addColumn('post_date', function ($row) {
$str = '';
if($row->post_status == 1) {
$str .= '<div style="color: green;">' . trans('label.publish') . '</div>';
}
if($row->post_status == 0) {
$str .= '<div style="color: red;">' . trans('label.draft') . '</div>';
}
$str .= Date('d-m-Y', strtotime($row->post_date));
return $str;
})
->addColumn('sum', function ($row) {
$str = trans('label.viewer') . ' : ' . $row->viewer . '<br>';
$str .= trans('label.command') . ' : ' . $row->comment_count;
return $str;
})
->rawColumns(['action', 'status', 'category', 'post_date', 'sum'])
->make(true);
}
}
......@@ -225,6 +225,7 @@ return [
'URL' => Illuminate\Support\Facades\URL::class,
'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class,
'Image' => Intervention\Image\Facades\Image::class,
],
......
......@@ -14,7 +14,7 @@ class CreateUsersTable extends Migration
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->sting('id', 36)->primary();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
......
......@@ -14,11 +14,11 @@ class CreateTableCategories extends Migration
public function up()
{
Schema::create('swp_categories', function (Blueprint $table) {
$table->string('id', 32)->primary();
$table->string('id', 36)->primary();
$table->string('name');
$table->boolean('is_active')->nullable();
$table->string('userid_created', 32)->nullable();
$table->string('userid_updated', 32)->nullable();
$table->string('userid_created', 36)->nullable();
$table->string('userid_updated', 36)->nullable();
$table->timestamps();
});
}
......
......@@ -14,11 +14,11 @@ class CreateCategoriesFileTable extends Migration
public function up()
{
Schema::create('swp_categories_file', function (Blueprint $table) {
$table->string('id', 32)->primary();
$table->string('id', 36)->primary();
$table->string('name');
$table->boolean('is_active')->nullable();
$table->string('userid_created', 32)->nullable();
$table->string('userid_updated', 32)->nullable();
$table->string('userid_created', 36)->nullable();
$table->string('userid_updated', 36)->nullable();
$table->timestamps();
});
}
......
......@@ -14,13 +14,13 @@ class CreateDesignTable extends Migration
public function up()
{
Schema::create('swp_design', function (Blueprint $table) {
$table->string('id', 32)->primary();
$table->string('id', 36)->primary();
$table->string('name_design');
$table->string('title_design')->nullable();
$table->text('value_design')->nullable();
$table->integer('urutan')->nullable();
$table->string('userid_created', 32)->nullable();
$table->string('userid_updated', 32)->nullable();
$table->string('userid_created', 36)->nullable();
$table->string('userid_updated', 36)->nullable();
$table->timestamps();
});
}
......
......@@ -14,15 +14,15 @@ class CreateFilesTable extends Migration
public function up()
{
Schema::create('swp_files', function (Blueprint $table) {
$table->string('id', 32);
$table->string('categories_file', 32);
$table->string('id', 36)->primary();
$table->string('categories_file', 36);
$table->string('title');
$table->string('file');
$table->boolean('is_active')->nullable();
$table->integer('downloaded')->nullable();
$table->string('slug')->nullable();
$table->string('userid_created', 32)->nullable();
$table->string('userid_updated', 32)->nullable();
$table->string('userid_created', 36)->nullable();
$table->string('userid_updated', 36)->nullable();
$table->timestamps();
});
}
......
......@@ -14,12 +14,12 @@ class CreateGaleriesTable extends Migration
public function up()
{
Schema::create('swp_galeries', function (Blueprint $table) {
$table->string('id', 32);
$table->string('id', 36)->primary();
$table->string('title');
$table->text('decription')->nullable();
$table->string('images')->nullable();
$table->string('userid_created', 32)->nullable();
$table->string('userid_updated', 32)->nullable();
$table->string('userid_created', 36)->nullable();
$table->string('userid_updated', 36)->nullable();
$table->boolean('is_active')->nullable();
$table->timestamps();
});
......
......@@ -14,15 +14,15 @@ class CreateInformationsTable extends Migration
public function up()
{
Schema::create('swp_informations', function (Blueprint $table) {
$table->string('id', 32);
$table->string('id', 36)->primary();
$table->string('title');
$table->text('content')->nullable();
$table->boolean('info_status')->nullable();
$table->integer('viewer')->nullable();
$table->string('slug')->nullable();
$table->date('event_date')->nullable();
$table->string('userid_created', 32)->nullable();
$table->string('userid_updated', 32)->nullable();
$table->string('userid_created', 36)->nullable();
$table->string('userid_updated', 36)->nullable();
$table->timestamps();
});
}
......
......@@ -14,7 +14,7 @@ class CreateMenusTable extends Migration
public function up()
{
Schema::create('swp_menus', function (Blueprint $table) {
$table->string('id', 32);
$table->string('id', 36)->primary();
$table->string('name');
$table->string('url')->nullable();
$table->string('mode')->nullable();
......@@ -23,8 +23,8 @@ class CreateMenusTable extends Migration
$table->integer('urutan')->nullable();
$table->integer('parentlevel')->nullable();
$table->integer('level')->nullable();
$table->string('userid_created', 32)->nullable();
$table->string('userid_updated', 32)->nullable();
$table->string('userid_created', 36)->nullable();
$table->string('userid_updated', 36)->nullable();
$table->timestamps();
});
}
......
......@@ -14,10 +14,10 @@ class CreatePagesTable extends Migration
public function up()
{
Schema::create('swp_pages', function (Blueprint $table) {
$table->string('id', 32);
$table->string('id', 36)->primary();
$table->string('title');
$table->text('content')->nullable();
$table->string('categories', 32);
$table->string('categories', 36);
$table->string('thumbnail')->nullable();
$table->timestamp('post_date')->nullable();
$table->boolean('post_status')->nullable();
......@@ -26,8 +26,8 @@ class CreatePagesTable extends Migration
$table->integer('viewer')->nullable();
$table->integer('comment_count')->nullable();
$table->string('slug')->nullable();
$table->string('userid_created', 32)->nullable();
$table->string('userid_updated', 32)->nullable();
$table->string('userid_created', 36)->nullable();
$table->string('userid_updated', 36)->nullable();
$table->timestamps();
});
}
......
......@@ -14,20 +14,21 @@ class CreatePostsTable extends Migration
public function up()
{
Schema::create('swp_posts', function (Blueprint $table) {
$table->string('id', 32);
$table->string('id', 36)->primary();
$table->string('title');
$table->text('content')->nullable();
$table->string('categories', 32);
$table->string('categories', 36);
$table->string('thumbnail')->nullable();
$table->timestamp('post_date')->nullable();
$table->boolean('post_status')->nullable();
$table->boolean('cover_status')->nullable();
$table->string('posts_password')->nullable();
$table->boolean('comment_status')->nullable();
$table->integer('viewer')->nullable();
$table->integer('comment_count')->nullable();
$table->string('slug')->nullable();
$table->string('userid_created', 32)->nullable();
$table->string('userid_updated', 32)->nullable();
$table->string('userid_created', 36)->nullable();
$table->string('userid_updated', 36)->nullable();
$table->timestamps();
});
}
......
......@@ -14,11 +14,11 @@ class CreateSettingsTable extends Migration
public function up()
{
Schema::create('swp_settings', function (Blueprint $table) {
$table->string('id', 32);
$table->string('id', 36)->primary();
$table->string('name_setting');
$table->string('value_setting');
$table->string('userid_created', 32)->nullable();
$table->string('userid_updated', 32)->nullable();
$table->string('userid_created', 36)->nullable();
$table->string('userid_updated', 36)->nullable();
$table->timestamps();
});
}
......
......@@ -14,13 +14,13 @@ class CreateSlidersTable extends Migration
public function up()
{
Schema::create('swp_sliders', function (Blueprint $table) {
$table->string('id', 32);
$table->string('id', 36)->primary();
$table->string('title');
$table->string('images')->nullable();
$table->text('content')->nullable();
$table->boolean('is_active')->nullable();
$table->string('userid_created', 32)->nullable();
$table->string('userid_updated', 32)->nullable();
$table->string('userid_created', 36)->nullable();
$table->string('userid_updated', 36)->nullable();
$table->timestamps();
});
}
......
$(function () {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
var table = $('.data-table').DataTable({
processing: true,
serverSide: true,
responsive: true,
ajax: url,
columns: [
{ data: 'DT_RowIndex', name: 'DT_RowIndex' },
{ data: 'title', name: 'title' },
{ data: 'category', name: 'category' },
{ data: 'post_date', name: 'post_date' },
{ data: 'sum', name: 'sum' },
{ data: 'action', name: 'action', orderable: false, searchable: false },
],
columnDefs: [
{ className: 'text-center', targets: [0, 2, 3, 5]},
{ className: 'text-left', targets: [1]},
],
});
$("body").on("click", ".delete", function (e) {
e.preventDefault();
var id = $(this).data('id');
swal({
title: "Apakah Anda Yakin?",
text: "Anda akan menghapus data ini!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
cancelButtonText: "No",
closeOnConfirm: false,
closeOnCancel: false
},
function (isConfirm) {
if (isConfirm) {
swal.close();
setTimeout(function () {
$.ajax({
dataType: 'json',
type: 'DELETE',
url: url + '/' + id,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
}).done(function (data) {
table.draw();
swal({
title: "Data berhasil dihapus!",
type: "success",
timer: "3000"
});
});
}, 1000); // 1 second delay
}
else {
swal("Dibatalkan", "Data batal dihapus", "error");
}
}
);
});
});
$(function () {
//iCheck for checkbox and radio inputs
$('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
checkboxClass: 'icheckbox_minimal-blue',
radioClass: 'iradio_minimal-blue'
});
});
function printErrorMsg(msg) {
$(".print-error-msg").find("ul").html('');
$(".print-error-msg").css('display', 'block');
$.each(msg, function (key, value) {
$(".print-error-msg").find("ul").append('<li>' + value + '</li>');
});
}
<?php
return [
'dashboard' => 'Dashboard',
'create' => 'Create',
'edit' => 'Edit',
'update' => 'Update',
'delete' => 'Delete',
'save' => 'Save',
'number' => 'Num',
'name' => 'Name',
'status' => 'Status',
'action' => 'Action',
'title' => 'Title',
'category' => 'Category',
'date' => 'Date',
'sum' => 'Sum',
'publish' => 'Publish',
'draft' => 'Draft',
'cover_image' => 'Cover Image',
'show_in_post' => 'Show in post',
'show_in_page' => 'Show in page',
'viewer' => 'Viewer',
'command' => 'Command',
];
<?php
return [
'dashboard' => 'Beranda',
'create' => 'Tambah',
'edit' => 'Ubah',
'update' => 'Update',
'delete' => 'Hapus',
'save' => 'Simpan',
'number' => 'No',
'name' => 'Nama',
'status' => 'Status',
'action' => 'Aksi',
'title' => 'Judul',
'category' => 'Kategori',
'date' => 'Tanggal',
'sum' => 'Jumlah',
'publish' => 'Terbitkan',
'draft' => 'Rancangan',
'cover_image' => 'Gambar Cover',
'show_in_post' => 'Tampilkan dalam berita',
'show_in_page' => 'Tampilkan dalam halaman',
'viewer' => 'Penonton',
'command' => 'Komentar',
];
\ No newline at end of file
@extends('layouts.app')
@extends('webprofile.backend.layouts.master')
@section('content')
<div class="row">
<div class="col-lg-12">
<!-- START DEFAULT DATATABLE -->
<div class="panel panel-default">
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
......@@ -20,4 +24,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
......@@ -10,7 +10,7 @@
@stop
@section('breadcrumbs')
<li><a href="{{URL::to('dashboard')}}">Dashboard</a></li>
<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.category')</li>
@stop
......@@ -22,7 +22,7 @@
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! $title !!}</h3>
<a class="btn btn-info" href="{{URL::to('webprofile/category/create')}}" style="margin: 0cm 0px 0cm 10px;">Tambah</a>
<a class="btn btn-info" href="{{URL::to('webprofile/category/create')}}" style="margin: 0cm 0px 0cm 10px;">@lang('label.create')</a>
<ul class="panel-controls">
<li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
</ul>
......@@ -32,10 +32,10 @@
<table class="table table-hover data-table" width="100%">
<thead>
<tr>
<th width="7%">No</th>
<th width="63%">Nama</th>
<th width="10%">Status</th>
<th align="center" width="15%">Aksi</th>
<th width="7%">@lang('label.number')</th>
<th width="63%">@lang('label.name')</th>
<th width="10%">@lang('label.status')</th>
<th align="center" width="15%">@lang('label.action')</th>
</tr>
</thead>
<tbody></tbody>
......
@extends('webprofile.backend.layouts.master')
@section('title')
{{ $title }}
@stop
@section('assets')
<link rel="stylesheet" href="{!! asset('backend/assets/select2/select2.min.css') !!}">
<style media="screen">
.tkh{
color: black;
}
</style>
@stop
@section('breadcrumbs')
<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.create_post')</li>
@stop
@section('content')
<!-- page start-->
<div class="row">
{!! Form::open(array('url' => route('posts.store'), 'method' => 'POST', 'id' => 'posts', 'files' => true)) !!}
{!! csrf_field() !!}
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><strong>@lang('label.create')</strong> @lang('feature.post')</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="form-group @if ($errors->has('title')) has-error @endif">
<div class="col-md-12">
{{ Form::text('title', old('title'), array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;')) }}
@if ($errors->has('title'))
<label id="login-error" class="error" for="login">{{$errors->first('title')}}</label>
@endif
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group @if ($errors->has('categories')) has-error @endif" style="margin-top: 5px;">
<div class="col-md-12">
{{ Form::select('categories', $categories, old('categories'), ['class' => 'form-control select2', 'style' => 'width: 100%; font-size: 14pt;', 'id' => 'categories', 'placeholder' => app('translator')->getFromJson('feature.category'), 'required']) }}
@if ($errors->has('categories'))
<label id="login-error" class="error" for="login">{{$errors->first('categories')}}</label>
@endif
</div>
</div>
</div>
<div class="col-md-12">
<div class="block">
{{ Form::textarea('content', null, array('id'=>'content')) }}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><strong>@lang('label.publish')</strong></h3>
<ul class="panel-controls">
<li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
</ul>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="col-md-3 col-xs-12 control-label">@lang('label.date')</label>
<div class="col-md-12">
<div class="input-group">
{{ Form::text('post_date', date('Y-m-d'), array('class' => 'form-control datepicker')) }}
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group" style="padding-top: 10px;">
<label class="col-md-2 control-label">@lang('label.status')</label>
<div class="col-md-6">
<center><label class="switch">
{{ Form::checkbox('post_status', 1, true) }}
<span></span>
</label></center>
</div>
</div>
</div>
</div>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><strong>@lang('label.cover_image')</strong></h3>
<ul class="panel-controls">
<li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
</ul>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="col-md-2 control-label"></label>
<div class="col-md-12">
<center>
<div class="form-group">
<img id="uploadPreview" style="width: 200px; height: 100%;" src="https://statik.unesa.ac.id/profileunesa_konten_statik/images/preview.png"/><br>
</div>
<div class="form-group">
{{ Form::file('thumbnail', array('class'=>'fileinput btn-danger', 'id'=>'uploadImage', 'data-filename-placement'=>'inside', 'title'=>app('translator')->getFromJson('label.cover_image'), 'onchange'=>'PreviewImage();')) }}
</div>
<div class="form-group" style="padding-top: 10px;">
<div class="col-md-12">
<div class="form-group">
<label style="vertical-align: middle;">@lang('label.show_in_post')</label>
<label class="switch" style="vertical-align: middle;">
{{ Form::checkbox('cover_status', 1, true) }}
<span></span>
</label>
</div>
</div>
</div>
</center>
</div>
</div>
</div>
</div>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-footer">
<button class="btn btn-info pull-right">@lang('label.save')</button>
</div>
</div>
</div>
{!! Form::close() !!}
</div>
<!-- page end-->
@stop
@section('script')
{!! Html::script('backend/assets/select2/select2.full.min.js') !!}
{!! Html::script('backend/js/plugins/bootstrap/bootstrap-datepicker.js') !!}
{!! Html::script('backend/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!}
{!! Html::script('backend/js/plugins/bootstrap/bootstrap-file-input.js') !!}
{!! Html::script('backend/js/plugins/summernote/summernote.js') !!}
<script type="text/javascript">
function PreviewImage() {
var oFReader = new FileReader();
oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]);
oFReader.onload = function (oFREvent) {
document.getElementById("uploadPreview").src = oFREvent.target.result;
};
};
$(document).ready(function() {
$('#content').summernote({
height: 400
});
});
$('#categories').select2();
</script>
@stop
@extends('webprofile.backend.layouts.master')
@section('title')
{{ $title }}
@stop
@section('assets')
<link rel="stylesheet" href="{!! asset('backend/assets/select2/select2.min.css') !!}">
<style media="screen">
.tkh{
color: black;
}
</style>
@stop
@section('breadcrumbs')
<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.create_post')</li>
@stop
@section('content')
<!-- page start-->
<div class="row">
{!! Form::model($data, ['route' => ['posts.update', $data->id], 'method'=>'patch', 'files' => true]) !!}
{!! csrf_field() !!}
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><strong>@lang('label.create')</strong> @lang('feature.post')</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="form-group @if ($errors->has('title')) has-error @endif">
<div class="col-md-12">
{{ Form::text('title', old('title'), array('class' => 'form-control', 'placeholder'=>app('translator')->getFromJson('label.title'), 'style'=>'font-size: 14pt;')) }}
@if ($errors->has('title'))
<label id="login-error" class="error" for="login">{{$errors->first('title')}}</label>
@endif
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group @if ($errors->has('categories')) has-error @endif" style="margin-top: 5px;">
<div class="col-md-12">
{{ Form::select('categories', $categories, old('categories'), ['class' => 'form-control select2', 'style' => 'width: 100%; font-size: 14pt;', 'id' => 'categories', 'placeholder' => app('translator')->getFromJson('feature.category'), 'required']) }}
@if ($errors->has('categories'))
<label id="login-error" class="error" for="login">{{$errors->first('categories')}}</label>
@endif
</div>
</div>
</div>
<div class="col-md-12">
<div class="block">
{{ Form::textarea('content', null, array('id'=>'content')) }}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><strong>@lang('label.publish')</strong></h3>
<ul class="panel-controls">
<li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
</ul>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="col-md-3 col-xs-12 control-label">@lang('label.date')</label>
<div class="col-md-12">
<div class="input-group">
{{ Form::text('post_date', date('Y-m-d'), array('class' => 'form-control datepicker')) }}
</div>
</div>
</div>
</div>
<div class="col-md-12">
<div class="form-group" style="padding-top: 10px;">
<label class="col-md-2 control-label">@lang('label.status')</label>
<div class="col-md-6">
<center><label class="switch">
{{ Form::checkbox('post_status', $data->post_status, $data->post_status) }}
<span></span>
</label></center>
</div>
</div>
</div>
</div>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><strong>@lang('label.cover_image')</strong></h3>
<ul class="panel-controls">
<li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
</ul>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label class="col-md-2 control-label"></label>
<div class="col-md-12">
<center>
<div class="form-group">
@if($data->thumbnail)
<img id="uploadPreview" style="width: 200px; height: 100%;" src="{{URL::to('https://statik.unesa.ac.id/profileunesa_konten_statik/uploads'. Session::get('ss_setting')['statik_konten'] .'/posts/'.$data->thumbnail)}}"/><br>
@else
<img id="uploadPreview" style="width: 200px; height: 100%;" src="//placehold.it/200x100&text=Preview"/><br>
@endif
</div>
<div class="form-group">
{{ Form::file('thumbnail', array('class'=>'fileinput btn-danger', 'id'=>'uploadImage', 'data-filename-placement'=>'inside', 'title'=>'Gambar cover', 'onchange'=>'PreviewImage();')) }}
</div>
<div class="form-group" style="padding-top: 10px;">
<div class="col-md-12">
<div class="form-group">
<label style="vertical-align: middle;">@lang('label.show_in_post')</label>
<label class="switch" style="vertical-align: middle;">
{{ Form::checkbox('cover_status', $data->cover_status, $data->cover_status) }}
<span></span>
</label>
</div>
</div>
</div>
</center>
</div>
</div>
</div>
</div>
</div>
<div class="panel-footer">
</div>
</div>
</div>
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-footer">
<button class="btn btn-info pull-right">@lang('label.save')</button>
</div>
</div>
</div>
{!! Form::close() !!}
</div>
<!-- page end-->
@stop
@section('script')
{!! Html::script('backend/assets/select2/select2.full.min.js') !!}
{!! Html::script('backend/js/plugins/bootstrap/bootstrap-datepicker.js') !!}
{!! Html::script('backend/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!}
{!! Html::script('backend/js/plugins/bootstrap/bootstrap-file-input.js') !!}
{!! Html::script('backend/js/plugins/summernote/summernote.js') !!}
<script type="text/javascript">
function PreviewImage() {
var oFReader = new FileReader();
oFReader.readAsDataURL(document.getElementById("uploadImage").files[0]);
oFReader.onload = function (oFREvent) {
document.getElementById("uploadPreview").src = oFREvent.target.result;
};
};
$(document).ready(function() {
$('#content').summernote({
height: 400
});
});
$('#categories').select2();
</script>
@stop
@extends('webprofile.backend.layouts.master')
@section('assets')
<link rel="stylesheet" href="{!! asset('backend/js/datatables.net-bs/css/dataTables.bootstrap.min.css') !!}">
<meta name="csrf-token" content="{{ csrf_token() }}">
@endsection
@section('title')
{{ $title }}
@stop
@section('breadcrumbs')
<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.post')</li>
@stop
@section('content')
<!-- page start-->
<div class="row">
<div class="col-lg-12">
<!-- START DEFAULT DATATABLE -->
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! $title !!}</h3>
<a class="btn btn-info" href="{{URL::to('webprofile/posts/create')}}" style="margin: 0cm 0px 0cm 10px;">@lang('label.create')</a>
<ul class="panel-controls">
<li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
</ul>
</div>
<div class="panel-body">
<table class="table table-hover data-table" width="100%">
<thead>
<tr>
<th width="7%" style="text-align: center;">@lang('label.number')</th>
<th width="38%" style="text-align: center;">@lang('label.title')</th>
<th width="15%" style="text-align: center;">@lang('label.category')</th>
<th width="15%" style="text-align: center;">@lang('label.date')</th>
<th width="15%" style="text-align: center;">@lang('label.sum')</th>
<th align="center" width="10%" style="text-align: center;">@lang('label.action')</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
<!-- END DEFAULT DATATABLE -->
</div>
</div>
<!-- page end-->
@stop
@section('script')
<script src="{!!asset('backend/js/datatables.net/js/jquery.dataTables.min.js') !!}"></script>
<script src="{!!asset('backend/js/datatables.net-bs/js/dataTables.bootstrap.min.js') !!}"></script>
<script src="{{ url('backend/assets/plugins/jquery-datatable/buttons/dataTables.buttons.min.js') }}"></script>
<script src="{{ url('backend/assets/plugins/jquery-datatable/buttons/buttons.bootstrap4.min.js') }}"></script>
<script src="{{ url('backend/assets/plugins/jquery-datatable/buttons/buttons.colVis.min.js') }}"></script>
<script src="{{ url('backend/assets/plugins/jquery-datatable/buttons/buttons.html5.min.js') }}"></script>
<script src="{{ url('backend/assets/plugins/jquery-datatable/buttons/buttons.print.min.js') }}"></script>
<script>
var url = "{{ route('posts.index') }}";
</script>
{{ Html::script('js/master/post.js') }}
@stop
......@@ -3,6 +3,7 @@ Route::group(['middleware' => 'auth'], function () {
// Route::group(['middleware' => 'role:admin'], function () {
Route::group(['namespace' => 'Webprofile\Backend', 'prefix' => 'webprofile'], function () {
Route::resource('category', 'CategoryController');
Route::resource('posts', 'PostController');
});
// });
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment