fix redirect back reklame and tourisms
This commit is contained in:
@@ -15,7 +15,7 @@ class AdvertisementController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$menuId = (int) $request->query('menu_id', 0);
|
||||
$menuId = $request->query('menu_id', 0);
|
||||
$permissions = $this->permissions[$menuId] ?? []; // Avoid undefined index error
|
||||
|
||||
$creator = $permissions['allow_create'] ?? 0;
|
||||
@@ -39,7 +39,7 @@ class AdvertisementController extends Controller
|
||||
*/
|
||||
public function create(Request $request)
|
||||
{
|
||||
$menuId = (int) $request->query('menu_id', 0);
|
||||
$menuId = $request->query('menu_id', 0);
|
||||
$title = 'Advertisement';
|
||||
$subtitle = 'Create Data';
|
||||
|
||||
@@ -64,7 +64,7 @@ class AdvertisementController extends Controller
|
||||
*/
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
$menuId = (int) $request->query('menu_id', 0);
|
||||
$menuId = $request->query('menu_id', 0);
|
||||
info("AdvertisementController@edit diakses dengan ID: $id");
|
||||
$title = 'Advertisement';
|
||||
$subtitle = 'Update Data';
|
||||
|
||||
@@ -15,41 +15,30 @@ class TourismController extends Controller
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
$menuId = $request->query('menu_id');
|
||||
$user = Auth::user();
|
||||
$userId = $user->id;
|
||||
$menuId = $request->query('menu_id', 0);
|
||||
$permissions = $this->permissions[$menuId] ?? []; // Avoid undefined index error
|
||||
|
||||
// Ambil role_id yang dimiliki user
|
||||
$roleIds = DB::table('user_role')
|
||||
->where('user_id', $userId)
|
||||
->pluck('role_id');
|
||||
|
||||
// Ambil data akses berdasarkan role_id dan menu_id
|
||||
$roleAccess = DB::table('role_menu')
|
||||
->whereIn('role_id', $roleIds)
|
||||
->where('menu_id', $menuId)
|
||||
->first();
|
||||
|
||||
// Pastikan roleAccess tidak null sebelum mengakses properti
|
||||
$creator = $roleAccess->allow_create ?? 0;
|
||||
$updater = $roleAccess->allow_update ?? 0;
|
||||
$destroyer = $roleAccess->allow_destroy ?? 0;
|
||||
return view('data.tourisms.index', compact('creator', 'updater', 'destroyer'));
|
||||
$creator = $permissions['allow_create'] ?? 0;
|
||||
$updater = $permissions['allow_update'] ?? 0;
|
||||
$destroyer = $permissions['allow_destroy'] ?? 0;
|
||||
return view('data.tourisms.index', compact('creator', 'updater', 'destroyer', 'menuId'));
|
||||
}
|
||||
|
||||
/**
|
||||
* show the form for creating a new rsource.
|
||||
*/
|
||||
public function bulkCreate()
|
||||
public function bulkCreate(Request $request)
|
||||
{
|
||||
return view('data.tourisms.form-upload');
|
||||
$menuId = $request->query('menu_id', 0);
|
||||
return view('data.tourisms.form-upload', compact('menuId'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show th form for creating a new resource
|
||||
*/
|
||||
public function create()
|
||||
public function create(Request $request)
|
||||
{
|
||||
$menuId = $request->query('menu_id', 0);
|
||||
$title = 'Pariwisata';
|
||||
$subtitle = 'Create Data';
|
||||
|
||||
@@ -64,14 +53,15 @@ class TourismController extends Controller
|
||||
|
||||
$apiUrl = url('/api/tourisms');
|
||||
|
||||
return view('data.tourisms.form', compact('title', 'subtitle', 'fields', 'fieldTypes', 'apiUrl', 'dropdownOptions'));
|
||||
return view('data.tourisms.form', compact('title', 'subtitle', 'fields', 'fieldTypes', 'apiUrl', 'dropdownOptions', 'menuId'));
|
||||
}
|
||||
|
||||
/**
|
||||
* show the form for editing the specified resource.
|
||||
*/
|
||||
public function edit($id)
|
||||
public function edit(Request $request, $id)
|
||||
{
|
||||
$menuId = $request->query('menu_id', 0);
|
||||
$title = 'Pariwisata';
|
||||
$subtitle = 'Update Data';
|
||||
|
||||
@@ -98,7 +88,7 @@ class TourismController extends Controller
|
||||
|
||||
$apiUrl = url('/api/tourisms');
|
||||
|
||||
return view('data.tourisms.form', compact('title', 'subtitle', 'modelInstance', 'fields', 'fieldTypes', 'apiUrl', 'dropdownOptions'));
|
||||
return view('data.tourisms.form', compact('title', 'subtitle', 'modelInstance', 'fields', 'fieldTypes', 'apiUrl', 'dropdownOptions', 'menuId'));
|
||||
}
|
||||
|
||||
private function getFields()
|
||||
|
||||
@@ -37,7 +37,8 @@ const dataAdvertisementsColumns = [
|
||||
actionButtons += `
|
||||
<button class="btn btn-warning me-2 btn-edit"
|
||||
data-id="${id}"
|
||||
data-model="${model}">
|
||||
data-model="${model}"
|
||||
data-menu="${menuId}">
|
||||
<i class='bx bx-edit'></i>
|
||||
</button>`;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
const form = document.querySelector("form#create-update-form");
|
||||
var authLogo = document.querySelector(".auth-logo");
|
||||
let menuId = document.getElementById("menuId").value;
|
||||
console.log(menuId);
|
||||
|
||||
if (!saveButton || !form) return;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ console.log(dropzonePreviewNode);
|
||||
.getAttribute("content")}`,
|
||||
},
|
||||
init: function () {
|
||||
let menuId = document.getElementById("menuId").value;
|
||||
// Listen for the success event
|
||||
this.on("success", function (file, response) {
|
||||
console.log("File successfully uploaded:", file);
|
||||
@@ -39,7 +40,7 @@ console.log(dropzonePreviewNode);
|
||||
"Upload Files";
|
||||
// Tunggu sebentar lalu reload halaman
|
||||
setTimeout(() => {
|
||||
window.location.href = "/data/web-advertisements";
|
||||
window.location.href = `/data/web-advertisements?menu_id=${menuId}`;
|
||||
}, 2000);
|
||||
});
|
||||
// Listen for the error event
|
||||
|
||||
@@ -11,6 +11,7 @@ const tableElement = document.getElementById("tourisms-data-table");
|
||||
const canView = "1";
|
||||
const canUpdate = tableElement.getAttribute("data-updater") === "1";
|
||||
const canDelete = tableElement.getAttribute("data-destroyer") === "1";
|
||||
let menuId = document.getElementById("menuId").value;
|
||||
|
||||
const dataTourismsColumns = [
|
||||
"No",
|
||||
@@ -32,7 +33,7 @@ const dataTourismsColumns = [
|
||||
const district = row.cells[4].data;
|
||||
const long = row.cells[9].data;
|
||||
const lat = row.cells[10].data;
|
||||
const model = "data/tourisms";
|
||||
const model = "data/web-tourisms";
|
||||
|
||||
let actionButtons = '<div class="d-flex justify-items-end gap-10">';
|
||||
let hasPrivilege = false;
|
||||
@@ -53,7 +54,8 @@ const dataTourismsColumns = [
|
||||
actionButtons += `
|
||||
<button class="btn btn-warning me-2 btn-edit"
|
||||
data-id="${id}"
|
||||
data-model="${model}">
|
||||
data-model="${model}"
|
||||
data-menu="${menuId}">
|
||||
<i class='bx bx-edit'></i>
|
||||
</button>`;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
const modalButton = document.querySelector(".btn-modal");
|
||||
const form = document.querySelector("form#create-update-form");
|
||||
var authLogo = document.querySelector(".auth-logo");
|
||||
let menuId = document.getElementById("menuId").value;
|
||||
|
||||
if (!saveButton || !form) return;
|
||||
|
||||
@@ -73,7 +74,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
}, 3000);
|
||||
|
||||
setTimeout(() => {
|
||||
window.location.href = "/data/web-tourisms";
|
||||
window.location.href = `/data/web-tourisms?menu_id=${menuId}`;
|
||||
}, 3000);
|
||||
} else {
|
||||
if (authLogo) {
|
||||
|
||||
@@ -28,6 +28,7 @@ console.log(dropzonePreviewNode);
|
||||
.getAttribute("content")}`,
|
||||
},
|
||||
init: function () {
|
||||
let menuId = document.getElementById("menuId").value;
|
||||
// Listen for the success event
|
||||
this.on("success", function (file, response) {
|
||||
console.log("File successfully uploaded:", file);
|
||||
@@ -39,7 +40,7 @@ console.log(dropzonePreviewNode);
|
||||
"Upload Files";
|
||||
// Tunggu sebentar lalu reload halaman
|
||||
setTimeout(() => {
|
||||
window.location.href = "/data/web-tourisms";
|
||||
window.location.href = `/data/web-tourisms?menu_id=${menuId}`;
|
||||
}, 2000);
|
||||
});
|
||||
// Listen for the error event
|
||||
|
||||
@@ -13,10 +13,10 @@ class GeneralTable {
|
||||
|
||||
init() {
|
||||
const tableContainer = document.getElementById(this.tableId);
|
||||
|
||||
|
||||
// Kosongkan container sebelum render ulang
|
||||
tableContainer.innerHTML = "";
|
||||
|
||||
|
||||
const table = new Grid({
|
||||
columns: this.columns,
|
||||
search: this.options.search || {
|
||||
@@ -47,7 +47,7 @@ class GeneralTable {
|
||||
total: (data) => data.meta.total,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
table.render(tableContainer);
|
||||
this.handleActions();
|
||||
}
|
||||
@@ -88,13 +88,15 @@ class GeneralTable {
|
||||
handleCreate(event) {
|
||||
// Menggunakan model dan ID untuk membangun URL dinamis
|
||||
const model = event.target.getAttribute("data-model"); // Mengambil model dari data-model
|
||||
window.location.href = `${this.baseUrl}/${model}/create`;
|
||||
let menuId = event.target.getAttribute("data-menu");
|
||||
window.location.href = `${this.baseUrl}/${model}/create?menu_id=${menuId}`;
|
||||
}
|
||||
|
||||
handleBulkCreate(event) {
|
||||
// Menggunakan model dan ID untuk membangun URL dinamis
|
||||
const model = event.target.getAttribute("data-model");
|
||||
window.location.href = `${this.baseUrl}/${model}/bulk-create`;
|
||||
let menuId = event.target.getAttribute("data-menu");
|
||||
window.location.href = `${this.baseUrl}/${model}/bulk-create?menu_id=${menuId}`;
|
||||
}
|
||||
|
||||
// Fungsi untuk menangani edit
|
||||
@@ -103,7 +105,8 @@ class GeneralTable {
|
||||
const model = event.target.getAttribute("data-model"); // Mengambil model dari data-model
|
||||
console.log("Editing record with ID:", id);
|
||||
// Menggunakan model dan ID untuk membangun URL dinamis
|
||||
window.location.href = `${this.baseUrl}/${model}/${id}/edit`;
|
||||
let menuId = event.target.getAttribute("data-menu");
|
||||
window.location.href = `${this.baseUrl}/${model}/${id}/edit?menu_id=${menuId}`;
|
||||
}
|
||||
|
||||
// Fungsi untuk menangani delete
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
@section('content')
|
||||
|
||||
@include('layouts.partials/page-title', ['title' => 'Form', 'subtitle' => 'File Uploads'])
|
||||
|
||||
<input type="hidden" id="menuId" value="{{ $menuId ?? 0 }}">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
<div class="row">
|
||||
<div class="d-flex justify-content-end gap-10 pb-3">
|
||||
@if ($creator)
|
||||
<button class="btn btn-success me-2 width-lg btn-create" data-model="data/advertisements">
|
||||
<button class="btn btn-success me-2 width-lg btn-create" data-model="data/advertisements" data-menu="{{ $menuId }}">
|
||||
<i class='bx bxs-file-plus'></i>
|
||||
Create</button>
|
||||
<button class="btn btn-primary width-lg btn-bulk-create" data-model="data/advertisements">
|
||||
<button class="btn btn-primary width-lg btn-bulk-create" data-model="data/advertisements" data-menu="{{ $menuId }}">
|
||||
<i class='bx bx-upload' ></i>
|
||||
Bulk Create
|
||||
</button>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
@section('content')
|
||||
|
||||
@include('layouts.partials/page-title', ['title' => 'Form', 'subtitle' => 'File Uploads'])
|
||||
|
||||
<input type="hidden" id="menuId" value="{{ $menuId ?? 0 }}">
|
||||
<div class="row">
|
||||
<div class="col-xl-12">
|
||||
<div class="card">
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
@section('content')
|
||||
|
||||
@include('layouts.partials/page-title', ['title' => $title, 'subtitle' => $subtitle]) <!-- Menggunakan title dan subtitle dari controller -->
|
||||
|
||||
<input type="hidden" id="menuId" value="{{ $menuId ?? 0 }}">
|
||||
<div class="row d-flex justify-content-center">
|
||||
@if (session('error'))
|
||||
<div class="alert alert-danger">
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
@section('content')
|
||||
@include('layouts.partials/page-title', ['title' => 'Data', 'subtitle' => 'Pariwisata'])
|
||||
|
||||
<input type="hidden" id="menuId" value="{{ $menuId ?? 0 }}">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="card-title">Daftar Pariwisata</h5>
|
||||
@@ -15,10 +16,10 @@
|
||||
<div class="row">
|
||||
<div class="d-flex justify-content-end gap-10 pb-3">
|
||||
@if ($creator)
|
||||
<button class="btn btn-success me-2 width-lg btn-create" data-model="data/tourisms">
|
||||
<button class="btn btn-success me-2 width-lg btn-create" data-model="data/tourisms" data-menu="{{ $menuId }}">
|
||||
<i class='bx bxs-file-plus'></i>
|
||||
Create</button>
|
||||
<button class="btn btn-primary width-lg btn-bulk-create" data-model="data/tourisms">
|
||||
<button class="btn btn-primary width-lg btn-bulk-create" data-model="data/tourisms" data-menu="{{ $menuId }}">
|
||||
<i class='bx bx-upload' ></i>
|
||||
Bulk Create
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user