Commit 41af4b84 by Aan Choesni Herlingga

crud master information

parent d56c9620
<?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\InformationRepository;
class InformationController extends Controller
{
private $repo;
public function __construct(InformationRepository $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.informations.index')->withTitle(trans('feature.information'));
}
/**
* 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.informations.create', $data)->withTitle(trans('feature.create_information'));
}
/**
* 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('info_status', $data) ? $data['info_status'] = 1 : $data['info_status'] = 0;
$this->repo->store($data);
return redirect()->route('informations.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.informations.edit', $data)->withTitle(trans('feature.create_information'));
}
/**
* 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('info_status', $data) ? $data['info_status'] = 1 : $data['info_status'] = 0;
$information = $this->repo->findId($id);
$edit = $this->repo->update($data, $information);
return redirect()->route('informations.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']);
}
}
...@@ -35,23 +35,28 @@ class InformationRepository extends Repository ...@@ -35,23 +35,28 @@ class InformationRepository extends Repository
return DataTables::of($data) return DataTables::of($data)
->addIndexColumn() ->addIndexColumn()
->addColumn('action', function ($row) { ->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/informations/' . $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>'; $btn = $btn . '<br>';
return $btn; return $btn;
}) })
->addColumn('date', function ($row) {
$str = Date('d-m-Y', strtotime($row->event_date));
return $str;
})
->addColumn('status', function ($row) { ->addColumn('status', function ($row) {
if ($row->is_active == true) { if ($row->info_status == true) {
$str = '<div style="color: green;"><i class="fa fa-check"></i></div>'; $str = '<div style="color: green;"><i class="fa fa-check"></i></div>';
} else { } else {
$str = '<div style="color: red;"><i class="fa fa-times"></i></div>'; $str = '<div style="color: red;"><i class="fa fa-times"></i></div>';
} }
return $str; return $str;
}) })
->rawColumns(['action', 'status']) ->rawColumns(['action', 'status', 'date'])
->make(true); ->make(true);
} }
} }
$(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: 'date', name: 'date' },
{ data: 'status', name: 'status' },
{ data: 'action', name: 'action', orderable: false, searchable: false },
],
columnDefs: [
{ className: 'text-center', targets: [0, 2, 3, 4]},
{ 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>');
});
}
...@@ -22,4 +22,5 @@ return [ ...@@ -22,4 +22,5 @@ return [
'show_in_page' => 'Show in page', 'show_in_page' => 'Show in page',
'viewer' => 'Viewer', 'viewer' => 'Viewer',
'command' => 'Command', 'command' => 'Command',
'event_date' => 'Event Date',
]; ];
...@@ -22,4 +22,5 @@ return [ ...@@ -22,4 +22,5 @@ return [
'show_in_page' => 'Tampilkan dalam halaman', 'show_in_page' => 'Tampilkan dalam halaman',
'viewer' => 'Penonton', 'viewer' => 'Penonton',
'command' => 'Komentar', 'command' => 'Komentar',
'event_date' => 'Tanggal Kegiatan',
]; ];
\ No newline at end of file
@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_information')</li>
@stop
@section('content')
<!-- page start-->
<div class="row">
{!! Form::open(array('url' => route('informations.store'), 'method' => 'POST', 'id' => 'informations', '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.information')</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="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.event_date')</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('event_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('info_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-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
});
});
</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_information')</li>
@stop
@section('content')
<!-- page start-->
<div class="row">
{!! Form::model($data, ['route' => ['informations.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.page')</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="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.event_date')</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('event_date', null, 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('info_status', null, null) }}
<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-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
});
});
</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.information')</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/informations/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="5%" style="text-align: center;">@lang('label.number')</th>
<th style="text-align: center;">@lang('label.title')</th>
<th width="15%" style="text-align: center;">@lang('label.date')</th>
<th width="10%" style="text-align: center;">@lang('label.status')</th>
<th align="center" width="15%" 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('informations.index') }}";
</script>
{{ Html::script('js/master/information.js') }}
@stop
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
</ul> </ul>
</li> </li>
<li> <li>
<a href="{{ url('webprofile/admin/information') }}"><span class="fa fa-info-circle"></span><span class="xn-text">@lang('feature.information')</span></a> <a href="{{ url('webprofile/informations') }}"><span class="fa fa-info-circle"></span><span class="xn-text">@lang('feature.information')</span></a>
</li> </li>
<li> <li>
<a href="{{ url('webprofile/slider') }}"><span class="fa fa-sliders"></span><span class="xn-text">@lang('feature.slider')</span></a> <a href="{{ url('webprofile/slider') }}"><span class="fa fa-sliders"></span><span class="xn-text">@lang('feature.slider')</span></a>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
@section('breadcrumbs') @section('breadcrumbs')
<li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li> <li><a href="{{URL::to('dashboard')}}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.create_post')</li> <li class="active">@lang('feature.create_page')</li>
@stop @stop
@section('content') @section('content')
......
...@@ -5,6 +5,7 @@ Route::group(['middleware' => 'auth'], function () { ...@@ -5,6 +5,7 @@ Route::group(['middleware' => 'auth'], function () {
Route::resource('category', 'CategoryController'); Route::resource('category', 'CategoryController');
Route::resource('posts', 'PostController'); Route::resource('posts', 'PostController');
Route::resource('pages', 'PageController'); Route::resource('pages', 'PageController');
Route::resource('informations', 'InformationController');
}); });
// }); // });
}); });
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