update
parent
8d97b52c88
commit
867a4d60c7
|
@ -0,0 +1,166 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Master;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Support\Facades\Validator;
|
||||||
|
use Illuminate\Support\Facades\DB;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Support\Facades\Hash;
|
||||||
|
use App\Models\Master\Template;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class ResourceController extends Controller
|
||||||
|
{
|
||||||
|
protected $title = 'Data Resource';
|
||||||
|
protected $template = 'modules.master.resource';
|
||||||
|
protected $route = 'modules.master.resource';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
permission('is_read', $this->route, 'module',true);
|
||||||
|
|
||||||
|
$data['breadcrumbs'] = [
|
||||||
|
['name' => 'Dashboard','url' => url('dashboard')],
|
||||||
|
['name' => 'Master Data'],
|
||||||
|
['name' => 'Data Resource','active' => true],
|
||||||
|
];
|
||||||
|
$data['title'] = $this->title;
|
||||||
|
$data['route'] = $this->route;
|
||||||
|
return view($this->template.'.index',$data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function grid(Request $request)
|
||||||
|
{
|
||||||
|
|
||||||
|
$data = Template::all();
|
||||||
|
$_data = [];
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($data as $key => $row) {
|
||||||
|
|
||||||
|
|
||||||
|
$action = '';
|
||||||
|
|
||||||
|
if((permission('is_create', $this->route.'.*','module',false)) || (permission('is_update', $this->route.'.*','module',false))){
|
||||||
|
$action .= '<div class="flex gap-3 justify-center items-center flex-row">';
|
||||||
|
$action .= '<a href="'.url('master/resource/update/'.encode_id($row->MsTemplateId)).'" data-toggle="tooltip" title="Edit Data" class="btn btn-sm btn-block bg-primary"><i class="ri-pencil-line text-white"></i></a>';
|
||||||
|
$action .= '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$_data[] = [
|
||||||
|
'no' => $key+1,
|
||||||
|
'id' => encode_id($row->id),
|
||||||
|
'name' => @$row->name,
|
||||||
|
'action' => @$action,
|
||||||
|
];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// return response()->json($_data); // Return the data as a JSON response
|
||||||
|
return response()->json($_data);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
permission('is_read', $this->route, 'module',true);
|
||||||
|
|
||||||
|
$data['breadcrumbs'] = [
|
||||||
|
['name' => 'Dashboard','url' => url('dashboard')],
|
||||||
|
['name' => 'Master Data'],
|
||||||
|
['name' => 'Data Resource','active' => true],
|
||||||
|
];
|
||||||
|
$data['title'] = $this->title;
|
||||||
|
$data['route'] = $this->route;
|
||||||
|
return view($this->template.'.form',$data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
$keyId = decode_id($request->secure_id);
|
||||||
|
|
||||||
|
if(@$keyId){
|
||||||
|
Validator::make($request->all(), [
|
||||||
|
'name' => 'required',
|
||||||
|
])->validate();
|
||||||
|
|
||||||
|
$user = Template::find($keyId);
|
||||||
|
$user->name = $request->name;
|
||||||
|
$user->save();
|
||||||
|
}else{
|
||||||
|
Validator::make($request->all(), [
|
||||||
|
'name' => 'required',
|
||||||
|
])->validate();
|
||||||
|
|
||||||
|
$user = new Template;
|
||||||
|
$user->name = $request->name;
|
||||||
|
$user->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->back()->with([
|
||||||
|
'message' => 'Berhasil update data',
|
||||||
|
'type' => 'success',
|
||||||
|
]);
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return redirect()->back()->with([
|
||||||
|
'message' => $e->getMessage(),
|
||||||
|
'type' => "error"
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the specified resource.
|
||||||
|
*/
|
||||||
|
public function show(string $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for editing the specified resource.
|
||||||
|
*/
|
||||||
|
public function edit(string $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the specified resource in storage.
|
||||||
|
*/
|
||||||
|
public function update($id = null)
|
||||||
|
{
|
||||||
|
$data['breadcrumbs'] = [
|
||||||
|
['name' => 'Dashboard','url' => url('dashboard')],
|
||||||
|
['name' => 'Master Data'],
|
||||||
|
['name' => 'Data Topik','active' => true],
|
||||||
|
];
|
||||||
|
$keyId = decode_id($id);
|
||||||
|
$data['title'] = $this->title;
|
||||||
|
$data['route'] = $this->route;
|
||||||
|
$data['keyId'] = $id;
|
||||||
|
$data['item'] = Template::where('MsTemplateId',$keyId)->first();
|
||||||
|
return view($this->template.'.form',$data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the specified resource from storage.
|
||||||
|
*/
|
||||||
|
public function destroy(string $id)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
@extends('layouts.master')
|
||||||
|
@section('content')
|
||||||
|
<div class="flex flex-col gap-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<div class="flex justify-between items-center">
|
||||||
|
<h4 class="card-title">{{$title}}</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<form action="{{route($route.'.store')}}" method="POST" class="">
|
||||||
|
{{csrf_field()}}
|
||||||
|
<input type="hidden" name="secure_id" value="{{@$keyId}}">
|
||||||
|
<div class="p-6">
|
||||||
|
<div class="grid lg:grid-cols-2 gap-3">
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="mb-3">Nama Resource Data</label>
|
||||||
|
<input type="text" value="{{@$item->name ? @$item->name : old('name')}}" name="name" class="form-input @error('name') is-invalid @enderror" placeholder="Masukan Nama" required>
|
||||||
|
@error('name')
|
||||||
|
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
||||||
|
@enderror
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="p-6">
|
||||||
|
<a href="{{route($route.'.index')}}" class="btn bg-danger text-white"><i class="ri-close-line"></i> Batal</a>
|
||||||
|
<button type="submit" class="btn bg-success text-white"><i class="ri-save-line"></i> Simpan</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
@section('page-js')
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('.numberInput').on('input', function() {
|
||||||
|
this.value = this.value.replace(/[^0-9]/g, ''); // Hanya angka 0-9
|
||||||
|
});
|
||||||
|
$('#togglePassword').on('click', function() {
|
||||||
|
let passwordField = $('#password');
|
||||||
|
let icon = $(this).find('i');
|
||||||
|
|
||||||
|
// Cek apakah input saat ini bertipe password
|
||||||
|
if (passwordField.attr('type') === 'password') {
|
||||||
|
passwordField.attr('type', 'text'); // Ubah ke teks
|
||||||
|
icon.removeClass('fa-eye').addClass('fa-eye-slash'); // Ganti ikon
|
||||||
|
} else {
|
||||||
|
passwordField.attr('type', 'password'); // Ubah ke password
|
||||||
|
icon.removeClass('fa-eye-slash').addClass('fa-eye'); // Kembalikan ikon
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endsection
|
|
@ -0,0 +1,85 @@
|
||||||
|
@extends('layouts.master')
|
||||||
|
|
||||||
|
@section('css')
|
||||||
|
@endsection
|
||||||
|
@section('content')
|
||||||
|
<div class="flex flex-col gap-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<div class="flex justify-between items-center">
|
||||||
|
<h4 class="card-title">Data {{$title}}</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="p-6">
|
||||||
|
<div id="toolbar">
|
||||||
|
<a href="{{route($route.'.create')}}" class="btn bg-success text-white"><i class="ri-add-line"></i> Tambah Data</a>
|
||||||
|
</div>
|
||||||
|
<table class="gridjs-table"
|
||||||
|
data-search="true"
|
||||||
|
data-toggle="table"
|
||||||
|
data-pagination="true"
|
||||||
|
data-toolbar="#toolbar"
|
||||||
|
data-show-refresh="false"
|
||||||
|
data-url="{{route($route.'.grid')}}"
|
||||||
|
data-sort-name="ids"
|
||||||
|
data-sort-order="desc"
|
||||||
|
data-page-size="10"
|
||||||
|
data-id-field="id"
|
||||||
|
id="grid-data">
|
||||||
|
<thead class="gridjs-thead">
|
||||||
|
<tr class="gridjs-tr bg-secondary/10">
|
||||||
|
<th class="gridjs-td gridjs-th text-sm text-gray-500" data-width="10" data-field="action">#</th>
|
||||||
|
<th class="gridjs-td gridjs-th text-sm text-gray-500" data-width="10" data-field="no">No</th>
|
||||||
|
<th class="gridjs-td gridjs-th text-sm text-gray-500" data-field="name">Name</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="gridjs-tbody"></tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@endsection
|
||||||
|
@section('js')
|
||||||
|
<script type="text/javascript">
|
||||||
|
$("#grid-data").on("click", ".remove_data", function() {
|
||||||
|
var base_url = $(this).attr('data-href');
|
||||||
|
var id = $(this).attr('data-id');
|
||||||
|
swal({
|
||||||
|
title: "Hapus Data!",
|
||||||
|
text: "Apa anda yakin ingin menghapus data ini ?",
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
confirmButtonColor: "#DD6B55",
|
||||||
|
confirmButtonText: "Ya Hapus Sekarang",
|
||||||
|
cancelButtonText: "Tidak",
|
||||||
|
closeOnConfirm: true,
|
||||||
|
closeOnCancel: true
|
||||||
|
},
|
||||||
|
function(isConfirm) {
|
||||||
|
if(isConfirm){
|
||||||
|
|
||||||
|
request = $.ajax({
|
||||||
|
url: base_url,
|
||||||
|
type: "GET",
|
||||||
|
});
|
||||||
|
|
||||||
|
// Callback handler that will be called on success
|
||||||
|
request.done(function(response, textStatus, jqXHR){
|
||||||
|
console.log(response);
|
||||||
|
toastr.success("Berhasil Menhapus Data", 'Berhasil!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'});
|
||||||
|
$('#grid-data').bootstrapTable('refresh');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Callback handler that will be called on failure
|
||||||
|
request.fail(function (jqXHR, textStatus, errorThrown){
|
||||||
|
toastr.error(
|
||||||
|
"Gagal "+textStatus, errorThrown
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endsection
|
|
@ -14,7 +14,7 @@
|
||||||
<div class="grid lg:grid-cols-2 gap-3">
|
<div class="grid lg:grid-cols-2 gap-3">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="mb-3">Nama Topik</label>
|
<label class="mb-3">Nama Topik</label>
|
||||||
<input type="text" value="{{@$item->name ? @$item->name : old('name')}}" name="name" class="form-input @error('name') is-invalid @enderror" placeholder="Masukan Nama Instansi" required>
|
<input type="text" value="{{@$item->name ? @$item->name : old('name')}}" name="name" class="form-input @error('name') is-invalid @enderror" placeholder="Masukan Nama" required>
|
||||||
@error('name')
|
@error('name')
|
||||||
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
<span class="invalid-feedback" style="display: block!important;"><strong>{{$message}}</strong></span>
|
||||||
@enderror
|
@enderror
|
||||||
|
|
|
@ -4,6 +4,8 @@ use Illuminate\Support\Facades\Route;
|
||||||
use App\Http\Middleware\Session;
|
use App\Http\Middleware\Session;
|
||||||
use App\Http\Controllers\HomeController;
|
use App\Http\Controllers\HomeController;
|
||||||
use App\Http\Controllers\Master\InstansiController;
|
use App\Http\Controllers\Master\InstansiController;
|
||||||
|
use App\Http\Controllers\Master\ResourceController;
|
||||||
|
use App\Http\Controllers\Master\TopikController;
|
||||||
use App\Http\Controllers\Management\UserController;
|
use App\Http\Controllers\Management\UserController;
|
||||||
use App\Http\Controllers\Management\RoleController;
|
use App\Http\Controllers\Management\RoleController;
|
||||||
use App\Http\Controllers\Management\AksesController;
|
use App\Http\Controllers\Management\AksesController;
|
||||||
|
@ -31,6 +33,19 @@ Route::name('opendata.')->prefix('opendata')->group(function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::name('master.')->prefix('master')->group(function () {
|
Route::name('master.')->prefix('master')->group(function () {
|
||||||
|
|
||||||
|
Route::name('resource.')->prefix('resource')->group(function () {
|
||||||
|
Route::resource('/',ResourceController::class);
|
||||||
|
Route::get('grid',[ResourceController::class,'grid'])->name('grid');
|
||||||
|
Route::get('update/{id?}',[ResourceController::class,'update'])->name('update');
|
||||||
|
});
|
||||||
|
|
||||||
|
Route::name('topik.')->prefix('topik')->group(function () {
|
||||||
|
Route::resource('/',TopikController::class);
|
||||||
|
Route::get('grid',[TopikController::class,'grid'])->name('grid');
|
||||||
|
Route::get('update/{id?}',[TopikController::class,'update'])->name('update');
|
||||||
|
});
|
||||||
|
|
||||||
Route::name('instansi.')->prefix('instansi')->group(function () {
|
Route::name('instansi.')->prefix('instansi')->group(function () {
|
||||||
Route::resource('/',InstansiController::class);
|
Route::resource('/',InstansiController::class);
|
||||||
Route::get('grid',[InstansiController::class,'grid'])->name('grid');
|
Route::get('grid',[InstansiController::class,'grid'])->name('grid');
|
||||||
|
|
Loading…
Reference in New Issue