master category file

parent ec141ae4
<?php
namespace App\Http\Controllers\Webprofile\Backend;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Repositories\Webprofile\CategoryFileRepository;
class CategoriesFileController extends Controller
{
private $repo;
public function __construct(CategoryFileRepository $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.categoriesfile.index')->withTitle(trans('feature.categoryfile'));
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
return view('webprofile.backend.categoriesfile.create')->withTitle(trans('feature.create_categoryfile'));
}
/**
* 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('is_active', $data) ? $data['is_active'] = 1 : $data['is_active'] = 0;
$this->repo->store($data);
return redirect()->route('categoriesfile.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);
$data = [
'data' => $data,
];
return view('webprofile.backend.categoriesfile.edit', $data)->withTitle(trans('feature.edit_categoryfile'));
}
/**
* 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('is_active', $data) ? $data['is_active'] = 1 : $data['is_active'] = 0;
$category = $this->repo->findId($id);
$edit = $this->repo->update($data, $category);
return redirect()->route('categoriesfile.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,7 +35,7 @@ class CategoryFileRepository extends Repository
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/categoriesfile/' . $row->id . '/edit') . '" data-toggle="tooltip" data-id="' . $row->id . '" data-original-title="Edit" class="edit btn btn-warning btn-round btn-sm edit">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>';
......
$(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: 'name', name: 'name' },
{ data: 'status', name: 'status' },
{ data: 'action', name: 'action', orderable: false, searchable: false },
],
columnDefs: [
{ className: 'text-center', targets: [0, 3] },
{ className: 'text-left', targets: [1, 2] },
],
});
$("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>');
});
}
@extends('webprofile.backend.layouts.master')
@section('title')
{{ $title }}
@stop
@section('breadcrumbs')
<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.create_categoryfile')</li>
@stop
@section('content')
{!! Form::open(array('url' => route('categoriesfile.store'), 'method' => 'POST', 'id' => 'category', 'class' => 'form-horizontal')) !!}
{!! csrf_field() !!}
<!-- page start-->
<div class="row">
<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.categoryfile')</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="form-group @if ($errors->has('name')) has-error @endif">
<label class="col-md-2 control-label">@lang('feature.categoryfile')</label>
<div class="col-md-10">
{{ Form::text('name', old('name'), array('class' => 'form-control')) }}
@if ($errors->has('name'))
<label id="login-error" class="error" for="login">{{$errors->first('name')}}</label>
@endif
</div>
</div>
<div class="form-group" style="padding-top: 10px;">
<label class="col-md-2 control-label">@lang('label.status')</label>
<div class="col-md-10">
<label class="switch">
{{ Form::checkbox('is_active', null, null) }}
<span></span>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-footer">
<a href="{{ url('webprofile/categoriesfile') }}" class="btn btn-default pull-right">@lang('label.cancel')</a>
<button class="btn btn-info pull-right">@lang('label.save')</button>
</div>
</div>
</div>
</div>
{!! Form::close() !!}
<!-- page end-->
@stop
@section('script')
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-datepicker.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-file-input.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/summernote/summernote.js') !!}
@stop
@extends('webprofile.backend.layouts.master')
@section('title')
{{ $title }}
@stop
@section('breadcrumbs')
<li><a href="{{ url('dashboard') }}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.edit_categoriesfile')</li>
@stop
@section('content')
{!! Form::model($data, ['route' => ['categoriesfile.update', $data->id], 'method'=>'patch', 'class'=>'form-horizontal']) !!}
{!! csrf_field() !!}
<!-- page start-->
<div class="row">
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title"><strong>@lang('label.edit')</strong> @lang('feature.categoryfile')</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="form-group @if ($errors->has('name')) has-error @endif">
<label class="col-md-2 control-label">@lang('feature.categoryfile')</label>
<div class="col-md-10">
{{ Form::text('name', old('name'), array('class' => 'form-control')) }}
@if ($errors->has('name'))
<label id="login-error" class="error" for="login">{{$errors->first('name')}}</label>
@endif
</div>
</div>
<div class="form-group" style="padding-top: 10px;">
<label class="col-md-2 control-label">@lang('label.status')</label>
<div class="col-md-10">
<label class="switch">
{{ Form::checkbox('is_active', null, null) }}
<span></span>
</label>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-9">
<div class="panel panel-default">
<div class="panel-footer">
<a href="{{URL::to('webprofile/categoriesfile')}}" class="btn btn-default pull-right">@lang('label.cancel')</a>
<button class="btn btn-info pull-right">@lang('label.save')</button>
</div>
</div>
</div>
</div>
{!! Form::close() !!}
<!-- page end-->
@stop
@section('script')
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-datepicker.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-timepicker.min.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/bootstrap/bootstrap-file-input.js') !!}
{!! Html::script('https://statik.unesa.ac.id/perpus_konten_statik/admin/js/plugins/summernote/summernote.js') !!}
@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('dashboard') }}">@lang('label.dashboard')</a></li>
<li class="active">@lang('feature.categoryfile')</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/categoriesfile/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">
<div class="col-sm-12" style="overflow-x: auto">
<table class="table table-hover data-table" width="100%">
<thead>
<tr>
<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>
</table>
</div>
</div>
</div>
<!-- END DEFAULT DATATABLE -->
</div>
</div>
<!-- page end-->
@stop
@section('script')
<!-- DataTables -->
<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('categoriesfile.index') }}";
</script>
{{ Html::script('js/master/categoryfile.js') }}
@stop
......@@ -31,8 +31,8 @@
<li class="xn-openable">
<a href="#"><span class="fa fa-file-o"></span> <span class="xn-text">@lang('feature.file')</span></a>
<ul>
<li><a href="{{ url('webprofile/categoriesfile') }}">@lang('feature.categoryfile')</a></li>
<li><a href="{{ url('webprofile/file') }}">@lang('feature.file')</a></li>
<li><a href="{{ url('webprofile/categories_file') }}">@lang('feature.categoryfile')</a></li>
</ul>
</li>
<li>
......
......@@ -9,6 +9,7 @@ Route::group(['middleware' => 'auth'], function () {
Route::resource('settings', 'SettingController');
Route::resource('sliders', 'SliderController');
Route::resource('gallery', 'GalleryController');
Route::resource('categoriesfile', 'CategoriesFileController');
});
// });
});
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