Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Datatable Potensi #972

Merged
merged 3 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions app/Http/Controllers/Informasi/PotensiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,36 @@

namespace App\Http\Controllers\Informasi;

use App\Http\Controllers\Controller;
use App\Http\Requests\PotensiRequest;
use App\Models\Potensi;
use App\Models\TipePotensi;
use App\Http\Controllers\Controller;
use App\Http\Requests\PotensiRequest;
use Yajra\DataTables\Facades\DataTables;

class PotensiController extends Controller
{
public function index()
{
$page_title = 'Potensi';
$page_description = 'Daftar Potensi';
$potensis = Potensi::latest()->paginate(10);

return view('informasi.potensi.index', compact('page_title', 'page_description', 'potensis'));
return view('informasi.potensi.index', compact('page_title', 'page_description'));
}

public function getDataPotensi()
{
return DataTables::of(Potensi::query())
->addColumn('aksi', function ($row) {
$data['show_url'] = route('informasi.potensi.show', $row->id);

if (! auth()->guest()) {
$data['edit_url'] = route('informasi.potensi.edit', $row->id);
$data['delete_url'] = route('informasi.potensi.destroy', $row->id);
}

return view('forms.aksi', $data);
})
->make();
}

public function kategori()
Expand Down
3 changes: 2 additions & 1 deletion catatan_rilis.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ Di rilis versi v2406.1.0 di versi ini terdapat [untuk diisi] dan perbaikan lain

1. [#845](https://github.com/OpenSID/OpenDK/issues/845) Penggunaan laravel pint.
2. [#957](https://github.com/OpenSID/OpenDK/issues/957) Penyesuaian carbon menggunakan bawaan laravel.
3. [#968](https://github.com/OpenSID/OpenDK/issues/968) Penyesuaian modul regulasi menggunakan datatable.
3. [#968](https://github.com/OpenSID/OpenDK/issues/968) Penyesuaian modul regulasi menggunakan datatable.
4. [#969](https://github.com/OpenSID/OpenDK/issues/969) Penyesuaian modul potensi menggunakan datatable.
121 changes: 59 additions & 62 deletions resources/views/informasi/potensi/index.blade.php
Original file line number Diff line number Diff line change
@@ -1,73 +1,70 @@
@extends('layouts.dashboard_template')

@section('content')
<section class="content-header">
<h1>
{{ $page_title ?? 'Page Title' }}
<small>{{ $page_description ?? '' }}</small>
</h1>
<ol class="breadcrumb">
<li><a href="{{ route('dashboard') }}"><i class="fa fa-dashboard"></i> Dashboard</a></li>
<li class="active">{!! $page_title !!}</li>
</ol>
</section>
<section class="content-header">
<h1>
{{ $page_title ?? 'Page Title' }}
<small>{{ $page_description ?? '' }}</small>
</h1>
<ol class="breadcrumb">
<li><a href="{{ route('dashboard') }}"><i class="fa fa-dashboard"></i> Dashboard</a></li>
<li class="active">{!! $page_title !!}</li>
</ol>
</section>

<section class="content container-fluid">
<section class="content container-fluid">
@include('partials.flash_message')

@include('partials.flash_message')

<div class="box box-primary">
<div class="box-header with-border">
<a href="{{ route('informasi.potensi.create') }}" class="btn btn-primary btn-sm {{ auth()->guest() ? 'hidden' : '' }}" title="Tambah Data"><i class="fa fa-plus"></i>&ensp; Tambah</a>
<div class="box-tools pull-right col-sm-4">
{!! Form::select('kategori_id', \App\Models\TipePotensi::pluck('nama_kategori', 'id'), isset($_GET['id']) ? $_GET['id'] : 0, ['placeholder' => 'Semua Kategori', 'class' => 'form-control', 'id' => 'kategori_id', 'required' => true, 'onchange' => 'changeCategori(this)']) !!}
</div>
</div>
<!-- /.box-header -->
<div class="box-body">
@if (count($potensis) > 0)
@foreach ($potensis as $potensi)
<div class="row overflow-x">
<div class="col-md-3">
<img src="{{ is_img($potensi->file_gambar ?? null) }}" width="100%">
</div>
<div class="col-md-8">
<h3>{{ $potensi->nama_potensi }}</h3>
<article>
<p>{{ str_limit($potensi->deskripsi, 200, ' ...') }}</p>
</article>
<div class="pull-right button-group" style="position:relative; bottom:0px; margin-bottom: 0px;">
<a href="{{ route('informasi.potensi.show', $potensi->id) }}" class="btn btn-sm btn-info"><i class="fa fa-eye"></i>&nbsp; Detail</a>
@unless (!Auth::check())
<a href="{!! route('informasi.potensi.edit', $potensi->id) !!}" class="btn btn-sm btn-primary" title="Ubah" data-button="edit"><i class="fa fa-edit"></i>&nbsp; Ubah</a>

<a href="javascript:void(0)" class="" title="Hapus" data-href="{!! route('informasi.potensi.destroy', $potensi->id) !!}" data-button="delete" id="deleteModal">
<button type="button" class="btn btn-icon btn-danger btn-sm"><i class="fa fa-trash" aria-hidden="true"></i>&nbsp; Hapus</button>
</a>
@endunless
</div>
</div>
</div>
<hr>
@endforeach
@else
<h3>Data tidak ditemukan.</h3>
@endif
<div class="box-footer clearfix" style="padding:0px; margin: 0px !important;">
{{ $potensis->links() }}
</div>
<div class="box box-primary">
<div class="box-header with-border">
<a href="{{ route('informasi.potensi.create') }}"
class="btn btn-success btn-sm btn-social {{ auth()->guest() ? 'hidden' : '' }}" title="Tambah Data"><i
class="fa fa-plus"></i>&nbsp;Tambah</a>
</div>
<!-- /.box-header -->
<div class="box-body">
<div class="table-responsive">
<table class="table table-striped table-bordered" id="potensi-table">
<thead>
<tr>
<th style="max-width: 150px;">Aksi</th>
<th>Potensi</th>
</tr>
</thead>
</table>
</div>
</section>
</div>
</div>
</section>
@endsection

@include('partials.asset_datatables')

@push('scripts')
<script type="text/javascript">
function changeCategori(obj) {
document.location = "{{ route('informasi.potensi.kategori') }}" + '?id=' + obj.value;
}
</script>
@include('forms.datatable-vertical')
@include('forms.delete-modal')
@endpush
<script type="text/javascript">
$(document).ready(function() {
var data = $('#potensi-table').DataTable({
processing: true,
serverSide: false,
ajax: "{!! route('informasi.potensi.getdata') !!}",
columns: [{
data: 'aksi',
name: 'aksi',
class: 'text-center text-nowrap',
searchable: false,
orderable: false
},
{
data: 'nama_potensi',
name: 'nama_potensi'
},
],
order: [
[1, 'asc']
]
});
});
</script>
@include('forms.datatable-vertical')
@include('forms.delete-modal')
@endpush
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@
Route::group(['prefix' => 'potensi'], function () {
Route::get('/', ['as' => 'informasi.potensi.index', 'uses' => 'PotensiController@index']);
Route::get('show/{potensi}', ['as' => 'informasi.potensi.show', 'uses' => 'PotensiController@show']);
Route::get('getdata', ['as' => 'informasi.potensi.getdata', 'uses' => 'PotensiController@getDataPotensi']);
Route::get('create', ['as' => 'informasi.potensi.create', 'uses' => 'PotensiController@create']);
Route::post('store', ['as' => 'informasi.potensi.store', 'uses' => 'PotensiController@store']);
Route::get('edit/{potensi}', ['as' => 'informasi.potensi.edit', 'uses' => 'PotensiController@edit']);
Expand Down