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