Merge branch 'branch-jagad' into 'main'
Branch jagad See merge request fiqhpratama1/xpendify!43
This commit is contained in:
@@ -9,7 +9,6 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
|
|
||||||
class MenuMiddleware
|
class MenuMiddleware
|
||||||
{
|
{
|
||||||
|
|
||||||
public function handle($request, Closure $next)
|
public function handle($request, Closure $next)
|
||||||
{
|
{
|
||||||
$menu = Menu::new()
|
$menu = Menu::new()
|
||||||
@@ -19,57 +18,50 @@ class MenuMiddleware
|
|||||||
'data-widget' => 'treeview',
|
'data-widget' => 'treeview',
|
||||||
'role' => 'menu',
|
'role' => 'menu',
|
||||||
'data-accordion' => 'false'
|
'data-accordion' => 'false'
|
||||||
]);
|
])
|
||||||
|
->html('<li class="nav-item">
|
||||||
$menu->html('<li class="nav-item">
|
|
||||||
<a href="'.url('/').'" class="nav-link">
|
<a href="'.url('/').'" class="nav-link">
|
||||||
<i class="nav-icon mdi mdi-home"></i>
|
<i class="nav-icon mdi mdi-home"></i>
|
||||||
<p>Halaman Utama </p>
|
<p>Halaman Utama </p>
|
||||||
</a>
|
</a>
|
||||||
</li>');
|
</li>');
|
||||||
|
|
||||||
// Ambil data menu utama
|
|
||||||
$user = Auth::guard('admin')->user();
|
$user = Auth::guard('admin')->user();
|
||||||
$role = $user->roles->first();
|
$role = $user->roles->first();
|
||||||
$currentRoleId = $role ? $role->id : null;
|
$currentRoleId = $role ? $role->id : null;
|
||||||
|
|
||||||
$menus = DB::select("
|
if ($currentRoleId) {
|
||||||
SELECT m.*, rm.menu_id AS assigned_menu_id
|
// Single query to get all authorized menus
|
||||||
FROM menus m
|
$allMenus = DB::table('menus')
|
||||||
LEFT JOIN role_menu rm
|
->join('role_menu', 'menus.id', '=', 'role_menu.menu_id')
|
||||||
ON m.id = rm.menu_id
|
->where('role_menu.role_id', $currentRoleId)
|
||||||
WHERE m.parent_id IS NULL AND rm.role_id = '".$currentRoleId."'
|
->select('menus.*')
|
||||||
ORDER BY m.id
|
->orderBy('order', 'ASC')
|
||||||
");
|
->get();
|
||||||
|
|
||||||
foreach ($menus as $item) {
|
// Organize menus into parents and children
|
||||||
// Ambil submenu jika ada
|
$parents = $allMenus->where('parent_id', null);
|
||||||
$children = DB::select("
|
$childrenByParent = $allMenus->whereNotNull('parent_id')
|
||||||
SELECT m.*, rm.menu_id AS assigned_menu_id
|
->groupBy('parent_id');
|
||||||
FROM menus m
|
|
||||||
LEFT JOIN role_menu rm
|
|
||||||
ON m.id = rm.menu_id
|
|
||||||
WHERE m.parent_id = '".$item->id."' AND rm.role_id = '".$currentRoleId."'
|
|
||||||
ORDER BY m.id
|
|
||||||
");
|
|
||||||
|
|
||||||
|
foreach ($parents as $parent) {
|
||||||
|
$this->addMenuItems($menu, $parent, $childrenByParent->get($parent->id));
|
||||||
if (isset($children)) {
|
|
||||||
// Menu dengan child
|
|
||||||
$submenu = Menu::new()->addClass('nav nav-treeview');
|
|
||||||
|
|
||||||
foreach ($children as $child) {
|
|
||||||
|
|
||||||
$submenu->html(
|
|
||||||
'<li class="nav-item">' .
|
|
||||||
'<a href="' . url($child->url) . '" class="nav-link">' .
|
|
||||||
'<i class="' . $child->icon . ' nav-icon"></i>' .
|
|
||||||
'<p>' . $child->title . '</p>' .
|
|
||||||
'</a>' .
|
|
||||||
'</li>'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
view()->share('menu', $menu->render());
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function addMenuItems($menu, $item, $children)
|
||||||
|
{
|
||||||
|
if ($children && $children->isNotEmpty()) {
|
||||||
|
$submenu = Menu::new()->addClass('nav nav-treeview');
|
||||||
|
foreach ($children as $child) {
|
||||||
|
$submenu->html($this->createMenuItem($child));
|
||||||
|
}
|
||||||
|
|
||||||
$menu->html(
|
$menu->html(
|
||||||
'<li class="nav-item">' .
|
'<li class="nav-item">' .
|
||||||
'<a href="#" class="nav-link">' .
|
'<a href="#" class="nav-link">' .
|
||||||
@@ -80,21 +72,17 @@ class MenuMiddleware
|
|||||||
'</li>'
|
'</li>'
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Menu tanpa child
|
$menu->html($this->createMenuItem($item));
|
||||||
$menu->html(
|
}
|
||||||
'<li class="nav-item">' .
|
}
|
||||||
|
|
||||||
|
protected function createMenuItem($item)
|
||||||
|
{
|
||||||
|
return '<li class="nav-item">' .
|
||||||
'<a href="' . url($item->url) . '" class="nav-link">' .
|
'<a href="' . url($item->url) . '" class="nav-link">' .
|
||||||
'<i class="nav-icon ' . $item->icon . '"></i>' .
|
'<i class="' . ($item->parent_id ? 'nav-icon ' : '') . $item->icon . '"></i>' .
|
||||||
'<p>' . $item->title . '</p>' .
|
'<p>' . $item->title . '</p>' .
|
||||||
'</a>' .
|
'</a>' .
|
||||||
'</li>'
|
'</li>';
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
view()->share('menu', $menu->render());
|
|
||||||
|
|
||||||
return $next($request);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
"guzzlehttp/guzzle": "^7.9",
|
"guzzlehttp/guzzle": "^7.9",
|
||||||
"intervention/image": "^3.9",
|
"intervention/image": "^3.9",
|
||||||
"laravel/framework": "^11.31",
|
"laravel/framework": "^11.31",
|
||||||
|
"laravel/octane": "^2.6",
|
||||||
"laravel/tinker": "^2.9",
|
"laravel/tinker": "^2.9",
|
||||||
"laravel/ui": "^4.6",
|
"laravel/ui": "^4.6",
|
||||||
"laravolt/avatar": "^6.0",
|
"laravolt/avatar": "^6.0",
|
||||||
|
|||||||
Generated
+262
-1
@@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "5ba74d8866276fa9daa9d6c52fd9f690",
|
"content-hash": "2576aa0bcffcd93e0f78de10eefa63c1",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "barryvdh/laravel-dompdf",
|
"name": "barryvdh/laravel-dompdf",
|
||||||
@@ -1430,6 +1430,94 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-10-27T10:15:54+00:00"
|
"time": "2024-10-27T10:15:54+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "laminas/laminas-diactoros",
|
||||||
|
"version": "3.5.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/laminas/laminas-diactoros.git",
|
||||||
|
"reference": "143a16306602ce56b8b092a7914fef03c37f9ed2"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/143a16306602ce56b8b092a7914fef03c37f9ed2",
|
||||||
|
"reference": "143a16306602ce56b8b092a7914fef03c37f9ed2",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
|
||||||
|
"psr/http-factory": "^1.1",
|
||||||
|
"psr/http-message": "^1.1 || ^2.0"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"amphp/amp": "<2.6.4"
|
||||||
|
},
|
||||||
|
"provide": {
|
||||||
|
"psr/http-factory-implementation": "^1.0",
|
||||||
|
"psr/http-message-implementation": "^1.1 || ^2.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"ext-curl": "*",
|
||||||
|
"ext-dom": "*",
|
||||||
|
"ext-gd": "*",
|
||||||
|
"ext-libxml": "*",
|
||||||
|
"http-interop/http-factory-tests": "^2.2.0",
|
||||||
|
"laminas/laminas-coding-standard": "~2.5.0",
|
||||||
|
"php-http/psr7-integration-tests": "^1.4.0",
|
||||||
|
"phpunit/phpunit": "^10.5.36",
|
||||||
|
"psalm/plugin-phpunit": "^0.19.0",
|
||||||
|
"vimeo/psalm": "^5.26.1"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laminas": {
|
||||||
|
"module": "Laminas\\Diactoros",
|
||||||
|
"config-provider": "Laminas\\Diactoros\\ConfigProvider"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"files": [
|
||||||
|
"src/functions/create_uploaded_file.php",
|
||||||
|
"src/functions/marshal_headers_from_sapi.php",
|
||||||
|
"src/functions/marshal_method_from_sapi.php",
|
||||||
|
"src/functions/marshal_protocol_version_from_sapi.php",
|
||||||
|
"src/functions/normalize_server.php",
|
||||||
|
"src/functions/normalize_uploaded_files.php",
|
||||||
|
"src/functions/parse_cookie_header.php"
|
||||||
|
],
|
||||||
|
"psr-4": {
|
||||||
|
"Laminas\\Diactoros\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"BSD-3-Clause"
|
||||||
|
],
|
||||||
|
"description": "PSR HTTP Message implementations",
|
||||||
|
"homepage": "https://laminas.dev",
|
||||||
|
"keywords": [
|
||||||
|
"http",
|
||||||
|
"laminas",
|
||||||
|
"psr",
|
||||||
|
"psr-17",
|
||||||
|
"psr-7"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"chat": "https://laminas.dev/chat",
|
||||||
|
"docs": "https://docs.laminas.dev/laminas-diactoros/",
|
||||||
|
"forum": "https://discourse.laminas.dev",
|
||||||
|
"issues": "https://github.com/laminas/laminas-diactoros/issues",
|
||||||
|
"rss": "https://github.com/laminas/laminas-diactoros/releases.atom",
|
||||||
|
"source": "https://github.com/laminas/laminas-diactoros"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://funding.communitybridge.org/projects/laminas-project",
|
||||||
|
"type": "community_bridge"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-10-14T11:59:49+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel/framework",
|
"name": "laravel/framework",
|
||||||
"version": "v11.35.1",
|
"version": "v11.35.1",
|
||||||
@@ -1645,6 +1733,96 @@
|
|||||||
},
|
},
|
||||||
"time": "2024-12-12T18:25:58+00:00"
|
"time": "2024-12-12T18:25:58+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "laravel/octane",
|
||||||
|
"version": "v2.6.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/laravel/octane.git",
|
||||||
|
"reference": "6d46153a04d73d07466bbb1f70d827614dc131eb"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/laravel/octane/zipball/6d46153a04d73d07466bbb1f70d827614dc131eb",
|
||||||
|
"reference": "6d46153a04d73d07466bbb1f70d827614dc131eb",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"laminas/laminas-diactoros": "^3.0",
|
||||||
|
"laravel/framework": "^10.10.1|^11.0",
|
||||||
|
"laravel/prompts": "^0.1.24|^0.2.0|^0.3.0",
|
||||||
|
"laravel/serializable-closure": "^1.3|^2.0",
|
||||||
|
"nesbot/carbon": "^2.66.0|^3.0",
|
||||||
|
"php": "^8.1.0",
|
||||||
|
"symfony/console": "^6.0|^7.0",
|
||||||
|
"symfony/psr-http-message-bridge": "^2.2.0|^6.4|^7.0"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"spiral/roadrunner": "<2023.1.0",
|
||||||
|
"spiral/roadrunner-cli": "<2.6.0",
|
||||||
|
"spiral/roadrunner-http": "<3.3.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"guzzlehttp/guzzle": "^7.6.1",
|
||||||
|
"inertiajs/inertia-laravel": "^1.3.2|^2.0",
|
||||||
|
"laravel/scout": "^10.2.1",
|
||||||
|
"laravel/socialite": "^5.6.1",
|
||||||
|
"livewire/livewire": "^2.12.3|^3.0",
|
||||||
|
"mockery/mockery": "^1.5.1",
|
||||||
|
"nunomaduro/collision": "^6.4.0|^7.5.2|^8.0",
|
||||||
|
"orchestra/testbench": "^8.21|^9.0",
|
||||||
|
"phpstan/phpstan": "^1.10.15",
|
||||||
|
"phpunit/phpunit": "^10.4",
|
||||||
|
"spiral/roadrunner-cli": "^2.6.0",
|
||||||
|
"spiral/roadrunner-http": "^3.3.0"
|
||||||
|
},
|
||||||
|
"bin": [
|
||||||
|
"bin/roadrunner-worker",
|
||||||
|
"bin/swoole-server"
|
||||||
|
],
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"aliases": {
|
||||||
|
"Octane": "Laravel\\Octane\\Facades\\Octane"
|
||||||
|
},
|
||||||
|
"providers": [
|
||||||
|
"Laravel\\Octane\\OctaneServiceProvider"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "2.x-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Laravel\\Octane\\": "src"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Taylor Otwell",
|
||||||
|
"email": "taylor@laravel.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Supercharge your Laravel application's performance.",
|
||||||
|
"keywords": [
|
||||||
|
"frankenphp",
|
||||||
|
"laravel",
|
||||||
|
"octane",
|
||||||
|
"roadrunner",
|
||||||
|
"swoole"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/laravel/octane/issues",
|
||||||
|
"source": "https://github.com/laravel/octane"
|
||||||
|
},
|
||||||
|
"time": "2025-01-28T15:16:08+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "laravel/prompts",
|
"name": "laravel/prompts",
|
||||||
"version": "v0.3.2",
|
"version": "v0.3.2",
|
||||||
@@ -7103,6 +7281,89 @@
|
|||||||
],
|
],
|
||||||
"time": "2024-11-06T14:24:19+00:00"
|
"time": "2024-11-06T14:24:19+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "symfony/psr-http-message-bridge",
|
||||||
|
"version": "v7.2.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/symfony/psr-http-message-bridge.git",
|
||||||
|
"reference": "03f2f72319e7acaf2a9f6fcbe30ef17eec51594f"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/symfony/psr-http-message-bridge/zipball/03f2f72319e7acaf2a9f6fcbe30ef17eec51594f",
|
||||||
|
"reference": "03f2f72319e7acaf2a9f6fcbe30ef17eec51594f",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=8.2",
|
||||||
|
"psr/http-message": "^1.0|^2.0",
|
||||||
|
"symfony/http-foundation": "^6.4|^7.0"
|
||||||
|
},
|
||||||
|
"conflict": {
|
||||||
|
"php-http/discovery": "<1.15",
|
||||||
|
"symfony/http-kernel": "<6.4"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"nyholm/psr7": "^1.1",
|
||||||
|
"php-http/discovery": "^1.15",
|
||||||
|
"psr/log": "^1.1.4|^2|^3",
|
||||||
|
"symfony/browser-kit": "^6.4|^7.0",
|
||||||
|
"symfony/config": "^6.4|^7.0",
|
||||||
|
"symfony/event-dispatcher": "^6.4|^7.0",
|
||||||
|
"symfony/framework-bundle": "^6.4|^7.0",
|
||||||
|
"symfony/http-kernel": "^6.4|^7.0"
|
||||||
|
},
|
||||||
|
"type": "symfony-bridge",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Symfony\\Bridge\\PsrHttpMessage\\": ""
|
||||||
|
},
|
||||||
|
"exclude-from-classmap": [
|
||||||
|
"/Tests/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Fabien Potencier",
|
||||||
|
"email": "fabien@symfony.com"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Symfony Community",
|
||||||
|
"homepage": "https://symfony.com/contributors"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "PSR HTTP message bridge",
|
||||||
|
"homepage": "https://symfony.com",
|
||||||
|
"keywords": [
|
||||||
|
"http",
|
||||||
|
"http-message",
|
||||||
|
"psr-17",
|
||||||
|
"psr-7"
|
||||||
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/psr-http-message-bridge/tree/v7.2.0"
|
||||||
|
},
|
||||||
|
"funding": [
|
||||||
|
{
|
||||||
|
"url": "https://symfony.com/sponsor",
|
||||||
|
"type": "custom"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://github.com/fabpot",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
|
||||||
|
"type": "tidelift"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"time": "2024-09-26T08:57:56+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/routing",
|
"name": "symfony/routing",
|
||||||
"version": "v7.2.0",
|
"version": "v7.2.0",
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ use App\Http\Controllers\Backend\BudgetControlController;
|
|||||||
use App\Http\Controllers\Backend\ReportController;
|
use App\Http\Controllers\Backend\ReportController;
|
||||||
use App\Http\Controllers\Master\RegionController;
|
use App\Http\Controllers\Master\RegionController;
|
||||||
use App\Http\Controllers\Master\CabangController;
|
use App\Http\Controllers\Master\CabangController;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
Auth::routes();
|
Auth::routes();
|
||||||
require __DIR__ . '/api.php';
|
require __DIR__ . '/api.php';
|
||||||
@@ -198,3 +199,10 @@ Route::middleware(['auth:admin', 'menu'])->group(function () {
|
|||||||
Route::get('/auth/menu-tree/{id}', [MenuRoleController::class, 'index'])->name('auth.menurole.index');
|
Route::get('/auth/menu-tree/{id}', [MenuRoleController::class, 'index'])->name('auth.menurole.index');
|
||||||
Route::post('/auth/menu-tree/submit', [MenuRoleController::class, 'saveMenu'])->name('auth.menurole.submit');
|
Route::post('/auth/menu-tree/submit', [MenuRoleController::class, 'saveMenu'])->name('auth.menurole.submit');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Route::get('/check-workers', function (Request $request) {
|
||||||
|
return response()->json([
|
||||||
|
'octane_client' => app()->bound(\Laravel\Octane\Contracts\Client::class),
|
||||||
|
'worker_pid' => getmypid(),
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user