Compare commits

..

2 Commits
main ... ilham

Author SHA1 Message Date
ilhamwara 81b3798e05 update 2025-06-10 14:32:36 +07:00
ilhamwara 8daa8f6857 update 2025-06-10 14:22:32 +07:00
17 changed files with 311 additions and 34 deletions

View File

@ -0,0 +1,15 @@
<?php
namespace App\Models\Master;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class AccessMenu extends Model
{
use HasFactory;
protected $table = 'ms_access_menu';
protected $primaryKey = 'MsAccessMenuId';
protected $guarded = [];
}

View File

@ -0,0 +1,14 @@
<?php
namespace App\Models\Master;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Group extends Model
{
use HasFactory;
protected $table = 'ms_group';
protected $primaryKey = 'MsGroupId';
protected $guarded = [];
}

View File

@ -0,0 +1,170 @@
<?php
namespace App\Models\Master;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Menu extends Model
{
use HasFactory;
protected $table = 'ms_menu';
protected $primaryKey = 'MsMenuId';
protected $guarded = [];
public function submenu()
{
return $this->hasMany(Menu::class,'parent_id','id');
}
public static function coreMenus($type, array $status = [1]): mixed
{
return Menu::where('parent_id', '=', 0)
->where('menu_type', '=', $type)
->whereIn('status', $status);
}
public static function coreMenusByParent($id, array $status = [1]): mixed
{
return Menu::where('parent_id', '=', $id)
->whereIn('status', $status);
}
public static function getMenuByParentPosition($id, $type, array $active = [1], int $year = null): mixed
{
if ($year) {
$currYear = $year;
} else {
$currYear = date('Y');
}
return Menu::where('parent_id', '=', $id)
->where('menu_type', '=', $type)
->whereIn('status', $active)
->union(Menu::coreMenus($type, $active))
->orderBy('ordering')
->get();
}
/**
* @author alex.gz <amqit.consultant@gmail.com>
* @created 08/12/2023 12:53
*
* @param $type
* @param int|null $year
*
* @return mixed
*/
public static function getParentByType($type, int $year = null): mixed
{
if ($year) {
$currYear = $year;
} else {
$currYear = date('Y');
}
return Menu::where('parent_id', '=', 0)
->where('menu_type', '=', $type)
->union(Menu::coreMenus($type))
->orderBy('ordering')
->get();
}
/**
* @author alex.gz <amqit.consultant@gmail.com>
* @created 08/12/2023 18:07
*
* @param $type
* @param int|null $year
*
* @return mixed
*/
public static function getMenuByYear($type, int $year = null): mixed
{
if ($year) {
$currYear = $year;
} else {
$currYear = date('Y');
}
return Menu::where('parent_id', '=', 0)
->where('menu_type', '=', $type)
->where('status', '=', true)
->orderBy('ordering')
->get();
}
/**
* @author alex.gz <amqit.consultant@gmail.com>
* @created 08/12/2023 12:54
*
* @param $type
* @param int|null $year
*
* @return mixed
*/
public static function getParentByTypeStatus($type, int $year = null): mixed
{
if ($year) {
$currYear = $year;
} else {
$currYear = date('Y');
}
return Menu::where('parent_id', '=', 0)
->where('menu_type', '=', $type)
->where('status', '=', true)
->union(Menu::coreMenus($type))
->orderBy('ordering')
->get();
}
public static function getMenuByParent($id, array $active = [1], int $year = null): mixed
{
if ($year) {
$currYear = $year;
} else {
$currYear = date('Y');
}
return Menu::where('parent_id', '=', $id)
->union(Menu::coreMenusByParent($id, $active))
->whereIn('status', $active)
->orderBy('ordering')
->get();
}
public static function countMenuByYear(int $year): mixed
{
$model = Menu::where('status', '=', true);
return $model->count();
}
public static function getActiveById($id, int $year = null): mixed
{
if ($year) {
$currYear = $year;
} else {
$currYear = date('Y');
}
return Menu::where('id', '=', $id)
->where('status', '=', true)
->first();
}
public static function getActiveByPosition($type, int $year = null): mixed
{
if ($year) {
$currYear = $year;
} else {
$currYear = date('Y');
}
return Menu::where('menu_type', '=', $type)
->where('status', '=', true)
->union(Menu::coreMenus($type))
->orderBy('ordering')
->get();
}
}

View File

@ -1,32 +0,0 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('PeriodePelaporan', function (Blueprint $table) {
$table->id('PeriodePelaporanId');
$table->string('NamaPeriode');
$table->date('BulanAwal');
$table->date('BulanSelesai');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('PeriodePelaporan', function (Blueprint $table) {
//
});
}
};

View File

@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ms_menu', function (Blueprint $table) {
$table->id('MsMenuId');
$table->foreignId('parent_id')->index()->default(0)->comment('idx menu_id');
$table->string('title', 150);
$table->string('module', 150)->nullable();
$table->string('url', 150)->nullable();
$table->string('menu_type', 50)->index()->nullable()->comment('tb_menu_group alias');
$table->string('menu_icons', 50)->nullable();
$table->tinyInteger('ordering')->default(0);
$table->boolean('status')->default(true)->comment('True/False');
$table->foreignId('created_by')->default(0);
$table->foreignId('updated_by')->default(0)->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('menus');
}
};

View File

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ms_group', function (Blueprint $table) {
$table->id('MsGroupId');
$table->string('name', 50)->unique();
$table->string('alias', 50)->unique();
$table->boolean('status')->default(true)->comment('True/False');
$table->foreignId('created_by')->default(0);
$table->foreignId('updated_by')->default(0)->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('groups');
}
};

View File

@ -0,0 +1,41 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('ms_access_menu', function (Blueprint $table) {
$table->id('MsAccessMenuId');
$table->foreignId('ms_group_id')->comment('FK ms group');
$table->string('module', 150)->nullable();
$table->foreignId('ms_menu_id')->comment('FK tb_menu');
$table->string('menu_group', 20)->nullable()->default('adminsidebar');
$table->boolean('is_create')->default(false);
$table->boolean('is_read')->default(false);
$table->boolean('is_update')->default(false);
$table->boolean('is_delete')->default(false);
$table->boolean('is_verify')->default(false);
$table->boolean('is_approve')->default(false);
$table->boolean('is_download')->default(false);
$table->json('access')->nullable();
$table->timestamps();
$table->foreign('ms_menu_id')->references('MsMenuId')->on('ms_menu')->cascadeOnDelete();
$table->foreign('ms_group_id')->references('MsGroupId')->on('ms_group')->cascadeOnDelete();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('access_menus');
}
};

2
package-lock.json generated
View File

@ -1,5 +1,5 @@
{
"name": "skl2025",
"name": "skl",
"lockfileVersion": 3,
"requires": true,
"packages": {

View File

@ -79,7 +79,7 @@ Route::get('/search', [SearchController::class, 'index'])->name('search');
// Route::get('/dashboard', function () {
// return Inertia::render('dashboard');
// })->middleware(['auth','permission:Dashboard.index' ])->name('dashboard');
Route::middleware(['auth', PermissionMiddleware::using('Dashboard.index')])->group(function () {
Route::middleware(['auth'])->group(function () {
Route::get('/dashboard', DashboardController::class)->name('dashboard');
});