From a223163436a0df465b7e9ba9727eb0c9163c2083 Mon Sep 17 00:00:00 2001 From: Gilang Pratama Date: Wed, 6 Nov 2024 02:41:44 +0700 Subject: [PATCH 1/2] Update models auth. --- app/Models/System/AppInfo.php | 5 +++-- app/Models/System/Institution.php | 5 +++-- app/Models/System/Module.php | 5 +++-- app/Models/System/ModuleCustom.php | 5 +++-- app/Models/System/ModuleCustomUser.php | 5 +++-- app/Models/System/Navbar.php | 5 +++-- app/Models/System/Role.php | 5 +++-- app/Models/System/Subnavbar.php | 5 +++-- app/Models/User.php | 5 +++-- database/seeders/System/UserSeeder.php | 2 +- 10 files changed, 28 insertions(+), 19 deletions(-) diff --git a/app/Models/System/AppInfo.php b/app/Models/System/AppInfo.php index e7062d0..b7fd772 100644 --- a/app/Models/System/AppInfo.php +++ b/app/Models/System/AppInfo.php @@ -4,6 +4,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Auth; class AppInfo extends Model { @@ -15,12 +16,12 @@ protected static function boot() static::creating(function ($model) { $model->createdAt = $model->freshTimestamp(); - $model->createdBy = auth()->check() ? session('name') : "System"; + $model->createdBy = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = auth()->check() ? session('name') : "System"; + $model->updatedBy = Auth::check() ? session('name') : "System"; }); } } diff --git a/app/Models/System/Institution.php b/app/Models/System/Institution.php index eef08c8..85b3044 100644 --- a/app/Models/System/Institution.php +++ b/app/Models/System/Institution.php @@ -4,6 +4,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Auth; class Institution extends Model { @@ -15,12 +16,12 @@ protected static function boot() static::creating(function ($model) { $model->createdAt = $model->freshTimestamp(); - $model->createdBy = auth()->check() ? session('name') : "System"; + $model->createdBy = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = auth()->check() ? session('name') : "System"; + $model->updatedBy = Auth::check() ? session('name') : "System"; }); } } diff --git a/app/Models/System/Module.php b/app/Models/System/Module.php index 55766ad..a8063f6 100644 --- a/app/Models/System/Module.php +++ b/app/Models/System/Module.php @@ -4,6 +4,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Support\Facades\Auth; class Module extends Model { @@ -15,12 +16,12 @@ protected static function boot() static::creating(function ($model) { $model->createdAt = $model->freshTimestamp(); - $model->createdBy = auth()->check() ? session('name') : "System"; + $model->createdBy = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = auth()->check() ? session('name') : "System"; + $model->updatedBy = Auth::check() ? session('name') : "System"; }); } } diff --git a/app/Models/System/ModuleCustom.php b/app/Models/System/ModuleCustom.php index 5e8b223..cbd5b24 100644 --- a/app/Models/System/ModuleCustom.php +++ b/app/Models/System/ModuleCustom.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Support\Facades\Auth; class ModuleCustom extends Model { @@ -21,12 +22,12 @@ protected static function boot() static::creating(function ($model) { $model->createdAt = $model->freshTimestamp(); - $model->createdBy = auth()->check() ? session('name') : "System"; + $model->createdBy = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = auth()->check() ? session('name') : "System"; + $model->updatedBy = Auth::check() ? session('name') : "System"; }); } } diff --git a/app/Models/System/ModuleCustomUser.php b/app/Models/System/ModuleCustomUser.php index bcabfaa..b032bdb 100644 --- a/app/Models/System/ModuleCustomUser.php +++ b/app/Models/System/ModuleCustomUser.php @@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Support\Facades\Auth; class ModuleCustomUser extends Model { @@ -27,12 +28,12 @@ protected static function boot() static::creating(function ($model) { $model->createdAt = $model->freshTimestamp(); - $model->createdBy = auth()->check() ? session('name') : "System"; + $model->createdBy = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = auth()->check() ? session('name') : "System"; + $model->updatedBy = Auth::check() ? session('name') : "System"; }); } } diff --git a/app/Models/System/Navbar.php b/app/Models/System/Navbar.php index d325001..270167a 100644 --- a/app/Models/System/Navbar.php +++ b/app/Models/System/Navbar.php @@ -6,6 +6,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\HasMany; +use Illuminate\Support\Facades\Auth; class Navbar extends Model { @@ -22,12 +23,12 @@ protected static function boot() static::creating(function ($model) { $model->createdAt = $model->freshTimestamp(); - $model->createdBy = auth()->check() ? session('name') : "System"; + $model->createdBy = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = auth()->check() ? session('name') : "System"; + $model->updatedBy = Auth::check() ? session('name') : "System"; }); } } diff --git a/app/Models/System/Role.php b/app/Models/System/Role.php index aa7a4e7..a642ddf 100644 --- a/app/Models/System/Role.php +++ b/app/Models/System/Role.php @@ -4,6 +4,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Facades\Auth; class Role extends Model { @@ -15,12 +16,12 @@ protected static function boot() static::creating(function ($model) { $model->createdAt = $model->freshTimestamp(); - $model->createdBy = auth()->check() ? session('name') : "System"; + $model->createdBy = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = auth()->check() ? session('name') : "System"; + $model->updatedBy = Auth::check() ? session('name') : "System"; }); } } diff --git a/app/Models/System/Subnavbar.php b/app/Models/System/Subnavbar.php index 4f915a7..995cdf6 100644 --- a/app/Models/System/Subnavbar.php +++ b/app/Models/System/Subnavbar.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Factories\HasFactory; +use Illuminate\Support\Facades\Auth; class Subnavbar extends Model { @@ -21,12 +22,12 @@ protected static function boot() static::creating(function ($model) { $model->createdAt = $model->freshTimestamp(); - $model->createdBy = auth()->check() ? session('name') : "System"; + $model->createdBy = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = auth()->check() ? session('name') : "System"; + $model->updatedBy = Auth::check() ? session('name') : "System"; }); } } diff --git a/app/Models/User.php b/app/Models/User.php index 2474751..4436292 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -8,6 +8,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Foundation\Auth\User as Authenticatable; +use Illuminate\Support\Facades\Auth; class User extends Authenticatable { @@ -24,12 +25,12 @@ protected static function boot() static::creating(function ($model) { $model->createdAt = $model->freshTimestamp(); - $model->createdBy = auth()->check() ? session('name') : "System"; + $model->createdBy = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = auth()->check() ? session('name') : "System"; + $model->updatedBy = Auth::check() ? session('name') : "System"; }); } } diff --git a/database/seeders/System/UserSeeder.php b/database/seeders/System/UserSeeder.php index b26a181..74d1e87 100644 --- a/database/seeders/System/UserSeeder.php +++ b/database/seeders/System/UserSeeder.php @@ -16,7 +16,7 @@ public function run(): void 'role_id' => 1, 'name' => "Support Sistem", 'username' => "support", - 'password' => bcrypt('Kangketik@2023') + 'password' => bcrypt('Kangketik@2024') ]); } } From 59620e3fed729f295ee4ba700490b6750cb3a689 Mon Sep 17 00:00:00 2001 From: Gilang Pratama Date: Wed, 6 Nov 2024 04:42:48 +0700 Subject: [PATCH 2/2] implementing new standard. --- app/Http/Controllers/DashboardController.php | 3 +- app/Http/Controllers/PortalController.php | 7 +- app/Http/Controllers/ProfileController.php | 9 +- .../Report/ActivityLogController.php | 28 +++ .../Controllers/Report/ErrorLogController.php | 14 ++ .../Setting/InstitutionController.php | 2 - app/Http/Kernel.php | 1 + app/Http/Middleware/ActivityLogMiddleware.php | 57 +++++ .../Middleware/RedirectIfAuthenticated.php | 2 +- app/Models/System/ActivityLog.php | 25 ++ app/Models/System/AppInfo.php | 6 +- app/Models/System/Institution.php | 6 +- app/Models/System/Module.php | 6 +- app/Models/System/ModuleCustom.php | 6 +- app/Models/System/ModuleCustomUser.php | 6 +- app/Models/System/Navbar.php | 6 +- app/Models/System/Role.php | 6 +- app/Models/System/Subnavbar.php | 6 +- app/Models/User.php | 6 +- app/Providers/EventServiceProvider.php | 1 - app/Providers/RouteServiceProvider.php | 2 +- composer.json | 2 +- config/database.php | 54 ++--- config/filesystems.php | 16 +- config/laravel-log-reader.php | 7 + config/log-viewer.php | 218 ------------------ config/queue.php | 20 -- .../2023_08_15_155734_create_roles_table.php | 8 +- .../2023_08_15_155912_create_users_table.php | 8 +- ...2023_08_15_160108_create_navbars_table.php | 6 +- ...3_08_15_160339_create_subnavbars_table.php | 9 +- ...23_08_15_160647_create_app_infos_table.php | 6 +- ...2023_08_15_160920_create_modules_table.php | 6 +- ...08_21_182510_create_institutions_table.php | 6 +- ..._27_223813_create_module_customs_table.php | 6 +- ...23837_create_module_custom_users_table.php | 6 +- ...1_06_034040_create_activity_logs_table.php | 41 ++++ .../Module/Support/GeneralSettingSeeder.php | 5 +- database/seeders/System/RoleSeeder.php | 9 - .../AdministrationSubnavbarSeeder.php | 4 +- .../Subnavbar/MasterSubnavbarSeeder.php | 4 +- .../Subnavbar/ReportSubnavbarSeeder.php | 13 +- .../Subnavbar/SettingSubnavbarSeeder.php | 8 +- resources/js/pages/report/error-log.js | 68 ++++++ resources/views/_layout/nav.blade.php | 2 +- .../pages/report/activity-log/index.blade.php | 100 ++++++++ .../pages/report/error-log/index.blade.php | 65 ++++++ routes/web.php | 11 +- 48 files changed, 514 insertions(+), 399 deletions(-) create mode 100644 app/Http/Controllers/Report/ActivityLogController.php create mode 100644 app/Http/Controllers/Report/ErrorLogController.php create mode 100644 app/Http/Middleware/ActivityLogMiddleware.php create mode 100644 app/Models/System/ActivityLog.php create mode 100644 config/laravel-log-reader.php delete mode 100644 config/log-viewer.php create mode 100644 database/migrations/2024_11_06_034040_create_activity_logs_table.php create mode 100644 resources/js/pages/report/error-log.js create mode 100644 resources/views/pages/report/activity-log/index.blade.php create mode 100644 resources/views/pages/report/error-log/index.blade.php diff --git a/app/Http/Controllers/DashboardController.php b/app/Http/Controllers/DashboardController.php index bbf4b56..8527555 100644 --- a/app/Http/Controllers/DashboardController.php +++ b/app/Http/Controllers/DashboardController.php @@ -7,6 +7,7 @@ use App\Models\System\Module; use App\Models\System\ModuleCustom; use Illuminate\Http\RedirectResponse; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Session; class DashboardController extends Controller @@ -70,7 +71,7 @@ public function switch_task(Request $request): RedirectResponse public function reset(): RedirectResponse { - $user = auth()->user(); + $user = Auth::user(); $session = array( 'role_id' => $user?->role_id, 'role_name' => $user?->roles?->name, diff --git a/app/Http/Controllers/PortalController.php b/app/Http/Controllers/PortalController.php index 6247321..f0afa92 100644 --- a/app/Http/Controllers/PortalController.php +++ b/app/Http/Controllers/PortalController.php @@ -6,6 +6,7 @@ use App\Models\System\AppInfo; use App\Models\System\Institution; use Illuminate\Http\RedirectResponse; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Session; use Illuminate\View\View; @@ -25,9 +26,9 @@ public function auth(Request $request): RedirectResponse 'password' => 'required' ]); - if (auth()->attempt($formFields)) { + if (Auth::attempt($formFields)) { $request->session()->regenerate(); - $user = auth()->user(); + $user = Auth::user(); // Create session $session = array( @@ -57,7 +58,7 @@ public function logout(Request $request): RedirectResponse private function invalidate_session(Request $request): void { - auth()->logout(); + Auth::logout(); $request->session()->invalidate(); $request->session()->regenerateToken(); $request->session()->flush(); diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index ec079cd..e1f9d17 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -5,6 +5,7 @@ use App\Models\User; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; use Illuminate\View\View; class ProfileController extends Controller @@ -13,7 +14,7 @@ class ProfileController extends Controller public function index(): View { - $data['user'] = auth()->user(); + $data['user'] = Auth::user(); return view('pages.profile', $data); } @@ -33,7 +34,7 @@ public function update(Request $request): RedirectResponse $formFields['picture'] = '/storage/images/profile/' . $filename; } - $user = User::find(auth()->user()?->id); + $user = User::find(Auth::user()?->id); $user?->update($formFields); $this->invalidate_session($request); @@ -48,7 +49,7 @@ public function reset(): RedirectResponse $newPassword = "USR" . $serialCode . "P"; $hashedPassword['password'] = bcrypt($newPassword); - $user = User::find(auth()->user()?->id); + $user = User::find(Auth::user()?->id); $user?->update($hashedPassword); return redirect($this->url)->with('alert', ['message' => 'Password has been reset, your new password is ' . $newPassword, 'status' => 'success']); @@ -56,7 +57,7 @@ public function reset(): RedirectResponse private function invalidate_session(Request $request): void { - auth()->logout(); + Auth::logout(); $request->session()->invalidate(); $request->session()->regenerateToken(); $request->session()->flush(); diff --git a/app/Http/Controllers/Report/ActivityLogController.php b/app/Http/Controllers/Report/ActivityLogController.php new file mode 100644 index 0000000..140cfc5 --- /dev/null +++ b/app/Http/Controllers/Report/ActivityLogController.php @@ -0,0 +1,28 @@ +input('dateStart'); + $dateEnd = $request->input('dateEnd'); + + if (!empty($dateStart)) { + $activityLogs->whereBetween('date', [$dateStart, $dateEnd]); + } + + $data['query'] = $request->input('query'); + $data['activityLog'] = $activityLogs->paginate(10)->appends($request->query()); + return view('pages.report.activity-log.index', $data); + } +} diff --git a/app/Http/Controllers/Report/ErrorLogController.php b/app/Http/Controllers/Report/ErrorLogController.php new file mode 100644 index 0000000..3194a13 --- /dev/null +++ b/app/Http/Controllers/Report/ErrorLogController.php @@ -0,0 +1,14 @@ + [ diff --git a/app/Http/Middleware/ActivityLogMiddleware.php b/app/Http/Middleware/ActivityLogMiddleware.php new file mode 100644 index 0000000..05f9986 --- /dev/null +++ b/app/Http/Middleware/ActivityLogMiddleware.php @@ -0,0 +1,57 @@ +path(); + + if ($auth) { + $logData['session_id'] = $request->session()->getId(); + $logData['date'] = date("Y-m-d"); + $logData['time'] = date("H:i:s"); + $logData['ip_address'] = $request->ip(); + $logData['method'] = $request->method(); + $logData['referer'] = $request->headers->get('referer'); + + if ($path == "/") { + $logData['path'] = "portal"; + } else { + $logData['path'] = $path; + } + + $logData['user'] = Auth::user()?->name; + $logData['role'] = Auth::user()?->roles?->name; + $logData['description'] = $logData['user'] . " (" . $logData['ip_address'] . ") telah mendarat di halaman " . $logData['path']; + + $activityLog = ActivityLog::where('date', $logData['date'])->where('session_id', $logData['session_id'])->where('path', $logData['path'])->first(); + + if ($logData['path'] != "dashboard") { + if (empty($activityLog)) { + ActivityLog::create($logData); + } else { + $newLogData['time'] = date("H:i:s"); + + $activityLog->increment('totalHit'); + $activityLog->update($newLogData); + } + } + } + + return $next($request); + } +} diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index d3033e7..6acc780 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -21,7 +21,7 @@ public function handle(Request $request, Closure $next, string ...$guards): Resp foreach ($guards as $guard) { if (Auth::guard($guard)->check()) { - $user = auth()->user(); + $user = Auth::user(); $url = $user?->roles?->dashboard_url; return redirect($url); diff --git a/app/Models/System/ActivityLog.php b/app/Models/System/ActivityLog.php new file mode 100644 index 0000000..1e91408 --- /dev/null +++ b/app/Models/System/ActivityLog.php @@ -0,0 +1,25 @@ +created_by = Auth::check() ? session('name') : "System"; + }); + + static::updating(function ($model) { + $model->updated_by = Auth::check() ? session('name') : null; + }); + } +} diff --git a/app/Models/System/AppInfo.php b/app/Models/System/AppInfo.php index b7fd772..18c3375 100644 --- a/app/Models/System/AppInfo.php +++ b/app/Models/System/AppInfo.php @@ -15,13 +15,11 @@ protected static function boot() parent::boot(); static::creating(function ($model) { - $model->createdAt = $model->freshTimestamp(); - $model->createdBy = Auth::check() ? session('name') : "System"; + $model->created_by = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { - $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = Auth::check() ? session('name') : "System"; + $model->updated_by = Auth::check() ? session('name') : null; }); } } diff --git a/app/Models/System/Institution.php b/app/Models/System/Institution.php index 85b3044..d244b2a 100644 --- a/app/Models/System/Institution.php +++ b/app/Models/System/Institution.php @@ -15,13 +15,11 @@ protected static function boot() parent::boot(); static::creating(function ($model) { - $model->createdAt = $model->freshTimestamp(); - $model->createdBy = Auth::check() ? session('name') : "System"; + $model->created_by = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { - $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = Auth::check() ? session('name') : "System"; + $model->updated_by = Auth::check() ? session('name') : null; }); } } diff --git a/app/Models/System/Module.php b/app/Models/System/Module.php index a8063f6..fe7a5c7 100644 --- a/app/Models/System/Module.php +++ b/app/Models/System/Module.php @@ -15,13 +15,11 @@ protected static function boot() parent::boot(); static::creating(function ($model) { - $model->createdAt = $model->freshTimestamp(); - $model->createdBy = Auth::check() ? session('name') : "System"; + $model->created_by = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { - $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = Auth::check() ? session('name') : "System"; + $model->updated_by = Auth::check() ? session('name') : null; }); } } diff --git a/app/Models/System/ModuleCustom.php b/app/Models/System/ModuleCustom.php index cbd5b24..17d6765 100644 --- a/app/Models/System/ModuleCustom.php +++ b/app/Models/System/ModuleCustom.php @@ -21,13 +21,11 @@ protected static function boot() parent::boot(); static::creating(function ($model) { - $model->createdAt = $model->freshTimestamp(); - $model->createdBy = Auth::check() ? session('name') : "System"; + $model->created_by = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { - $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = Auth::check() ? session('name') : "System"; + $model->updated_by = Auth::check() ? session('name') : null; }); } } diff --git a/app/Models/System/ModuleCustomUser.php b/app/Models/System/ModuleCustomUser.php index b032bdb..b071f48 100644 --- a/app/Models/System/ModuleCustomUser.php +++ b/app/Models/System/ModuleCustomUser.php @@ -27,13 +27,11 @@ protected static function boot() parent::boot(); static::creating(function ($model) { - $model->createdAt = $model->freshTimestamp(); - $model->createdBy = Auth::check() ? session('name') : "System"; + $model->created_by = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { - $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = Auth::check() ? session('name') : "System"; + $model->updated_by = Auth::check() ? session('name') : null; }); } } diff --git a/app/Models/System/Navbar.php b/app/Models/System/Navbar.php index 270167a..6ec45bb 100644 --- a/app/Models/System/Navbar.php +++ b/app/Models/System/Navbar.php @@ -22,13 +22,11 @@ protected static function boot() parent::boot(); static::creating(function ($model) { - $model->createdAt = $model->freshTimestamp(); - $model->createdBy = Auth::check() ? session('name') : "System"; + $model->created_by = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { - $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = Auth::check() ? session('name') : "System"; + $model->updated_by = Auth::check() ? session('name') : null; }); } } diff --git a/app/Models/System/Role.php b/app/Models/System/Role.php index a642ddf..34ba652 100644 --- a/app/Models/System/Role.php +++ b/app/Models/System/Role.php @@ -15,13 +15,11 @@ protected static function boot() parent::boot(); static::creating(function ($model) { - $model->createdAt = $model->freshTimestamp(); - $model->createdBy = Auth::check() ? session('name') : "System"; + $model->created_by = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { - $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = Auth::check() ? session('name') : "System"; + $model->updated_by = Auth::check() ? session('name') : null; }); } } diff --git a/app/Models/System/Subnavbar.php b/app/Models/System/Subnavbar.php index 995cdf6..17a1d49 100644 --- a/app/Models/System/Subnavbar.php +++ b/app/Models/System/Subnavbar.php @@ -21,13 +21,11 @@ protected static function boot() parent::boot(); static::creating(function ($model) { - $model->createdAt = $model->freshTimestamp(); - $model->createdBy = Auth::check() ? session('name') : "System"; + $model->created_by = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { - $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = Auth::check() ? session('name') : "System"; + $model->updated_by = Auth::check() ? session('name') : null; }); } } diff --git a/app/Models/User.php b/app/Models/User.php index 4436292..05eadae 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -24,13 +24,11 @@ protected static function boot() parent::boot(); static::creating(function ($model) { - $model->createdAt = $model->freshTimestamp(); - $model->createdBy = Auth::check() ? session('name') : "System"; + $model->created_by = Auth::check() ? session('name') : "System"; }); static::updating(function ($model) { - $model->updatedAt = $model->freshTimestamp(); - $model->updatedBy = Auth::check() ? session('name') : "System"; + $model->updated_by = Auth::check() ? session('name') : null; }); } } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 2d65aac..87c58d1 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -5,7 +5,6 @@ use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; -use Illuminate\Support\Facades\Event; class EventServiceProvider extends ServiceProvider { diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 1cf5f15..025e874 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -17,7 +17,7 @@ class RouteServiceProvider extends ServiceProvider * * @var string */ - public const HOME = '/home'; + public const HOME = '/dashboard'; /** * Define your route model bindings, pattern filters, and other route configuration. diff --git a/composer.json b/composer.json index fca785a..8f2cfcf 100644 --- a/composer.json +++ b/composer.json @@ -75,4 +75,4 @@ }, "minimum-stability": "stable", "prefer-stable": true -} \ No newline at end of file +} diff --git a/config/database.php b/config/database.php index 137ad18..1af850c 100644 --- a/config/database.php +++ b/config/database.php @@ -34,15 +34,6 @@ */ 'connections' => [ - - 'sqlite' => [ - 'driver' => 'sqlite', - 'url' => env('DATABASE_URL'), - 'database' => env('DB_DATABASE', database_path('database.sqlite')), - 'prefix' => '', - 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), - ], - 'mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), @@ -63,36 +54,23 @@ ]) : [], ], - 'pgsql' => [ - 'driver' => 'pgsql', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', '127.0.0.1'), - 'port' => env('DB_PORT', '5432'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', - 'prefix' => '', - 'prefix_indexes' => true, - 'search_path' => 'public', - 'sslmode' => 'prefer', - ], - - 'sqlsrv' => [ - 'driver' => 'sqlsrv', - 'url' => env('DATABASE_URL'), - 'host' => env('DB_HOST', 'localhost'), - 'port' => env('DB_PORT', '1433'), - 'database' => env('DB_DATABASE', 'forge'), - 'username' => env('DB_USERNAME', 'forge'), - 'password' => env('DB_PASSWORD', ''), - 'charset' => 'utf8', + 'resource' => [ + 'driver' => 'mysql', + 'host' => env('RESOURCE_HOST', '127.0.0.1'), + 'port' => env('RESOURCE_PORT', '3306'), + 'database' => env('RESOURCE_DATABASE', 'forge'), + 'username' => env('RESOURCE_USERNAME', 'forge'), + 'password' => env('RESOURCE_PASSWORD', ''), + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, - // 'encrypt' => env('DB_ENCRYPT', 'yes'), - // 'trust_server_certificate' => env('DB_TRUST_SERVER_CERTIFICATE', 'false'), + 'strict' => true, + 'engine' => null, + 'options' => extension_loaded('pdo_mysql') ? array_filter([ + PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), + ]) : [], ], - ], /* @@ -121,11 +99,11 @@ 'redis' => [ - 'client' => env('REDIS_CLIENT', 'phpredis'), + 'client' => env('REDIS_CLIENT', 'predis'), 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'redis'), - 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'), + 'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'), ], 'default' => [ diff --git a/config/filesystems.php b/config/filesystems.php index e9d9dbd..be6939c 100644 --- a/config/filesystems.php +++ b/config/filesystems.php @@ -29,7 +29,6 @@ */ 'disks' => [ - 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), @@ -39,23 +38,10 @@ 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), - 'url' => env('APP_URL').'/storage', + 'url' => env('APP_URL') . '/storage', 'visibility' => 'public', 'throw' => false, ], - - 's3' => [ - 'driver' => 's3', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'region' => env('AWS_DEFAULT_REGION'), - 'bucket' => env('AWS_BUCKET'), - 'url' => env('AWS_URL'), - 'endpoint' => env('AWS_ENDPOINT'), - 'use_path_style_endpoint' => env('AWS_USE_PATH_STYLE_ENDPOINT', false), - 'throw' => false, - ], - ], /* diff --git a/config/laravel-log-reader.php b/config/laravel-log-reader.php new file mode 100644 index 0000000..218ff16 --- /dev/null +++ b/config/laravel-log-reader.php @@ -0,0 +1,7 @@ + 'report/api/error-log', + 'admin_panel_path' => 'dashboard/task', + 'middleware' => ['web', 'auth'] +]; diff --git a/config/log-viewer.php b/config/log-viewer.php deleted file mode 100644 index 9a82110..0000000 --- a/config/log-viewer.php +++ /dev/null @@ -1,218 +0,0 @@ - env('LOG_VIEWER_ENABLED', true), - - 'api_only' => env('LOG_VIEWER_API_ONLY', false), - - 'require_auth_in_production' => true, - - /* - |-------------------------------------------------------------------------- - | Log Viewer Domain - |-------------------------------------------------------------------------- - | You may change the domain where Log Viewer should be active. - | If the domain is empty, all domains will be valid. - | - */ - - 'route_domain' => null, - - /* - |-------------------------------------------------------------------------- - | Log Viewer Route - |-------------------------------------------------------------------------- - | Log Viewer will be available under this URL. - | - */ - - 'route_path' => 'report/activity-log', - - /* - |-------------------------------------------------------------------------- - | Back to system URL - |-------------------------------------------------------------------------- - | When set, displays a link to easily get back to this URL. - | Set to `null` to hide this link. - | - | Optional label to display for the above URL. - | - */ - - 'back_to_system_url' => config('app.url', null), - - 'back_to_system_label' => null, // Displayed by default: "Back to {{ app.name }}" - - /* - |-------------------------------------------------------------------------- - | Log Viewer time zone. - |-------------------------------------------------------------------------- - | The time zone in which to display the times in the UI. Defaults to - | the application's timezone defined in config/app.php. - | - */ - - 'timezone' => null, - - /* - |-------------------------------------------------------------------------- - | Log Viewer route middleware. - |-------------------------------------------------------------------------- - | Optional middleware to use when loading the initial Log Viewer page. - | - */ - - 'middleware' => [ - 'web', - \Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer::class, - ], - - /* - |-------------------------------------------------------------------------- - | Log Viewer API middleware. - |-------------------------------------------------------------------------- - | Optional middleware to use on every API request. The same API is also - | used from within the Log Viewer user interface. - | - */ - - 'api_middleware' => [ - \Opcodes\LogViewer\Http\Middleware\EnsureFrontendRequestsAreStateful::class, - \Opcodes\LogViewer\Http\Middleware\AuthorizeLogViewer::class, - ], - - 'api_stateful_domains' => env('LOG_VIEWER_API_STATEFUL_DOMAINS') ? explode(',', env('LOG_VIEWER_API_STATEFUL_DOMAINS')) : null, - - /* - |-------------------------------------------------------------------------- - | Log Viewer Remote hosts. - |-------------------------------------------------------------------------- - | Log Viewer supports viewing Laravel logs from remote hosts. They must - | be running Log Viewer as well. Below you can define the hosts you - | would like to show in this Log Viewer instance. - | - */ - - 'hosts' => [ - 'local' => [ - 'name' => ucfirst(env('APP_ENV', 'local')), - ], - - // 'staging' => [ - // 'name' => 'Staging', - // 'host' => 'https://staging.example.com/log-viewer', - // 'auth' => [ // Example of HTTP Basic auth - // 'username' => 'username', - // 'password' => 'password', - // ], - // ], - // - // 'production' => [ - // 'name' => 'Production', - // 'host' => 'https://example.com/log-viewer', - // 'auth' => [ // Example of Bearer token auth - // 'token' => env('LOG_VIEWER_PRODUCTION_TOKEN'), - // ], - // 'headers' => [ - // 'X-Foo' => 'Bar', - // ], - // ], - ], - - /* - |-------------------------------------------------------------------------- - | Include file patterns - |-------------------------------------------------------------------------- - | - */ - - 'include_files' => [ - '*.log', - '**/*.log', - - // You can include paths to other log types as well, such as apache, nginx, and more. - '/var/log/httpd/*', - '/var/log/nginx/*', - - // MacOS Apple Silicon logs - '/opt/homebrew/var/log/nginx/*', - '/opt/homebrew/var/log/httpd/*', - '/opt/homebrew/var/log/php-fpm.log', - '/opt/homebrew/var/log/postgres*log', - '/opt/homebrew/var/log/redis*log', - '/opt/homebrew/var/log/supervisor*log', - - // '/absolute/paths/supported', - ], - - /* - |-------------------------------------------------------------------------- - | Exclude file patterns. - |-------------------------------------------------------------------------- - | This will take precedence over included files. - | - */ - - 'exclude_files' => [ - // 'my_secret.log' - ], - - /* - |-------------------------------------------------------------------------- - | Hide unknown files. - |-------------------------------------------------------------------------- - | The include/exclude options above might catch files which are not - | logs supported by Log Viewer. In that case, you can hide them - | from the UI and API calls by setting this to true. - | - */ - - 'hide_unknown_files' => true, - - /* - |-------------------------------------------------------------------------- - | Shorter stack trace filters. - |-------------------------------------------------------------------------- - | Lines containing any of these strings will be excluded from the full log. - | This setting is only active when the function is enabled via the user interface. - | - */ - - 'shorter_stack_trace_excludes' => [ - '/vendor/symfony/', - '/vendor/laravel/framework/', - '/vendor/barryvdh/laravel-debugbar/', - ], - - /* - |-------------------------------------------------------------------------- - | Cache driver - |-------------------------------------------------------------------------- - | Cache driver to use for storing the log indices. Indices are used to speed up - | log navigation. Defaults to your application's default cache driver. - | - */ - - 'cache_driver' => env('LOG_VIEWER_CACHE_DRIVER', null), - - /* - |-------------------------------------------------------------------------- - | Chunk size when scanning log files lazily - |-------------------------------------------------------------------------- - | The size in MB of files to scan before updating the progress bar when searching across all files. - | - */ - - 'lazy_scan_chunk_size_in_mb' => 50, - - 'strip_extracted_context' => true, -]; diff --git a/config/queue.php b/config/queue.php index 01c6b05..80f6df7 100644 --- a/config/queue.php +++ b/config/queue.php @@ -42,26 +42,6 @@ 'after_commit' => false, ], - 'beanstalkd' => [ - 'driver' => 'beanstalkd', - 'host' => 'localhost', - 'queue' => 'default', - 'retry_after' => 90, - 'block_for' => 0, - 'after_commit' => false, - ], - - 'sqs' => [ - 'driver' => 'sqs', - 'key' => env('AWS_ACCESS_KEY_ID'), - 'secret' => env('AWS_SECRET_ACCESS_KEY'), - 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), - 'queue' => env('SQS_QUEUE', 'default'), - 'suffix' => env('SQS_SUFFIX'), - 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), - 'after_commit' => false, - ], - 'redis' => [ 'driver' => 'redis', 'connection' => 'default', diff --git a/database/migrations/2023_08_15_155734_create_roles_table.php b/database/migrations/2023_08_15_155734_create_roles_table.php index b8b7d8f..d2bf223 100644 --- a/database/migrations/2023_08_15_155734_create_roles_table.php +++ b/database/migrations/2023_08_15_155734_create_roles_table.php @@ -13,15 +13,13 @@ public function up(): void { Schema::create('roles', function (Blueprint $table) { $table->id(); - $table->string('code', 128); + $table->string('code', 128)->unique(); $table->string('name', 128); $table->string('description', 128); $table->string('dashboard_url', 128); $table->unsignedTinyInteger('is_landing')->default(0); - $table->string('createdBy')->default('System'); - $table->timestamp('createdAt')->default(now()); - $table->string('updatedBy')->nullable(true)->default(null); - $table->timestamp('updatedAt')->nullable(true)->default(null); + $table->string('created_by')->default('System'); + $table->string('updated_by')->nullable(true)->default(null); $table->timestamps(); }); } diff --git a/database/migrations/2023_08_15_155912_create_users_table.php b/database/migrations/2023_08_15_155912_create_users_table.php index 65acfcb..6180c8b 100644 --- a/database/migrations/2023_08_15_155912_create_users_table.php +++ b/database/migrations/2023_08_15_155912_create_users_table.php @@ -16,13 +16,11 @@ public function up(): void $table->unsignedBigInteger('role_id'); $table->string('name', 128); $table->string('picture')->default('/storage/images/profile/default.png'); - $table->string('username', 128); + $table->string('username', 128)->unique(); $table->string('password'); $table->enum('status', ['Active', 'Inactive'])->default('Active'); - $table->string('createdBy')->default('System'); - $table->timestamp('createdAt')->default(now()); - $table->string('updatedBy')->nullable(true)->default(null); - $table->timestamp('updatedAt')->nullable(true)->default(null); + $table->string('created_by')->default('System'); + $table->string('updated_by')->nullable(true)->default(null); $table->timestamps(); $table->foreign('role_id')->references('id')->on('roles')->onDelete('cascade'); }); diff --git a/database/migrations/2023_08_15_160108_create_navbars_table.php b/database/migrations/2023_08_15_160108_create_navbars_table.php index ac5bca2..54394e0 100644 --- a/database/migrations/2023_08_15_160108_create_navbars_table.php +++ b/database/migrations/2023_08_15_160108_create_navbars_table.php @@ -18,10 +18,8 @@ public function up(): void $table->string('url'); $table->string('roles')->default(1); $table->enum('type', ['single', 'dropdown'])->default('single'); - $table->string('createdBy')->default('System'); - $table->timestamp('createdAt')->default(now()); - $table->string('updatedBy')->nullable(true)->default(null); - $table->timestamp('updatedAt')->nullable(true)->default(null); + $table->string('created_by')->default('System'); + $table->string('updated_by')->nullable(true)->default(null); $table->timestamps(); }); } diff --git a/database/migrations/2023_08_15_160339_create_subnavbars_table.php b/database/migrations/2023_08_15_160339_create_subnavbars_table.php index c0282c7..ebc606e 100644 --- a/database/migrations/2023_08_15_160339_create_subnavbars_table.php +++ b/database/migrations/2023_08_15_160339_create_subnavbars_table.php @@ -14,13 +14,12 @@ public function up(): void Schema::create('subnavbars', function (Blueprint $table) { $table->id(); $table->unsignedBigInteger('navbar_id'); + $table->string('code')->unique()->nullable(true)->default(null); $table->string('name'); - $table->string('url'); + $table->string('url')->unique(); $table->string('roles')->default(1); - $table->string('createdBy')->default('System'); - $table->timestamp('createdAt')->default(now()); - $table->string('updatedBy')->nullable(true)->default(null); - $table->timestamp('updatedAt')->nullable(true)->default(null); + $table->string('created_by')->default('System'); + $table->string('updated_by')->nullable(true)->default(null); $table->timestamps(); $table->foreign('navbar_id')->references('id')->on('navbars')->onDelete('cascade'); }); diff --git a/database/migrations/2023_08_15_160647_create_app_infos_table.php b/database/migrations/2023_08_15_160647_create_app_infos_table.php index 60fed23..79d7022 100644 --- a/database/migrations/2023_08_15_160647_create_app_infos_table.php +++ b/database/migrations/2023_08_15_160647_create_app_infos_table.php @@ -22,10 +22,8 @@ public function up(): void $table->string('sponsor_url')->default(null)->nullable(true); $table->string('sponsor_logo')->default(null)->nullable(true); $table->unsignedTinyInteger('is_maintenance')->default(0); - $table->string('createdBy')->default('System'); - $table->timestamp('createdAt')->default(now()); - $table->string('updatedBy')->nullable(true)->default(null); - $table->timestamp('updatedAt')->nullable(true)->default(null); + $table->string('created_by')->default('System'); + $table->string('updated_by')->nullable(true)->default(null); $table->timestamps(); }); } diff --git a/database/migrations/2023_08_15_160920_create_modules_table.php b/database/migrations/2023_08_15_160920_create_modules_table.php index 8c40a2b..585fa17 100644 --- a/database/migrations/2023_08_15_160920_create_modules_table.php +++ b/database/migrations/2023_08_15_160920_create_modules_table.php @@ -21,10 +21,8 @@ public function up(): void $table->string('subnavbars'); $table->string('roles'); $table->string('role_code'); - $table->string('createdBy')->default('System'); - $table->timestamp('createdAt')->default(now()); - $table->string('updatedBy')->nullable(true)->default(null); - $table->timestamp('updatedAt')->nullable(true)->default(null); + $table->string('created_by')->default('System'); + $table->string('updated_by')->nullable(true)->default(null); $table->timestamps(); }); } diff --git a/database/migrations/2023_08_21_182510_create_institutions_table.php b/database/migrations/2023_08_21_182510_create_institutions_table.php index e595878..1231c51 100644 --- a/database/migrations/2023_08_21_182510_create_institutions_table.php +++ b/database/migrations/2023_08_21_182510_create_institutions_table.php @@ -21,10 +21,8 @@ public function up(): void $table->string('website'); $table->string('appUrl'); $table->string('contact')->nullable(true)->default(null); - $table->string('createdBy')->default('System'); - $table->timestamp('createdAt')->default(now()); - $table->string('updatedBy')->nullable(true)->default(null); - $table->timestamp('updatedAt')->nullable(true)->default(null); + $table->string('created_by')->default('System'); + $table->string('updated_by')->nullable(true)->default(null); $table->timestamps(); }); } diff --git a/database/migrations/2024_04_27_223813_create_module_customs_table.php b/database/migrations/2024_04_27_223813_create_module_customs_table.php index afdef74..a27b391 100644 --- a/database/migrations/2024_04_27_223813_create_module_customs_table.php +++ b/database/migrations/2024_04_27_223813_create_module_customs_table.php @@ -19,10 +19,8 @@ public function up(): void $table->string('url'); $table->string('navbars')->nullable(true)->default(null); $table->string('subnavbars')->nullable(true)->default(null); - $table->string('createdBy')->default('System'); - $table->timestamp('createdAt')->default(now()); - $table->string('updatedBy')->nullable(true)->default(null); - $table->timestamp('updatedAt')->nullable(true)->default(null); + $table->string('created_by')->default('System'); + $table->string('updated_by')->nullable(true)->default(null); $table->timestamps(); }); } diff --git a/database/migrations/2024_04_27_223837_create_module_custom_users_table.php b/database/migrations/2024_04_27_223837_create_module_custom_users_table.php index 44abc94..10deb07 100644 --- a/database/migrations/2024_04_27_223837_create_module_custom_users_table.php +++ b/database/migrations/2024_04_27_223837_create_module_custom_users_table.php @@ -15,10 +15,8 @@ public function up(): void $table->id(); $table->unsignedBigInteger('user_id'); $table->unsignedBigInteger('module_custom_id'); - $table->string('createdBy')->default('System'); - $table->timestamp('createdAt')->default(now()); - $table->string('updatedBy')->nullable(true)->default(null); - $table->timestamp('updatedAt')->nullable(true)->default(null); + $table->string('created_by')->default('System'); + $table->string('updated_by')->nullable(true)->default(null); $table->timestamps(); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('module_custom_id')->references('id')->on('module_customs')->onDelete('cascade'); diff --git a/database/migrations/2024_11_06_034040_create_activity_logs_table.php b/database/migrations/2024_11_06_034040_create_activity_logs_table.php new file mode 100644 index 0000000..02d550f --- /dev/null +++ b/database/migrations/2024_11_06_034040_create_activity_logs_table.php @@ -0,0 +1,41 @@ +id(); + $table->string('session_id'); + $table->date('date'); + $table->time('time'); + $table->string('user')->default('Guest'); + $table->string('role')->default('Guest'); + $table->string('ip_address'); + $table->string('method'); + $table->string('referer')->nullable(true)->default(null); + $table->string('path'); + $table->unsignedBigInteger('totalHit')->default(1); + $table->string('description'); + $table->string('created_by')->default('System'); + $table->string('updated_by')->nullable(true)->default(null); + $table->timestamps(); + $table->foreign('session_id')->references('id')->on('sessions')->onDelete('cascade'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('activity_logs'); + } +}; diff --git a/database/seeders/System/Module/Support/GeneralSettingSeeder.php b/database/seeders/System/Module/Support/GeneralSettingSeeder.php index db43d51..46f0410 100644 --- a/database/seeders/System/Module/Support/GeneralSettingSeeder.php +++ b/database/seeders/System/Module/Support/GeneralSettingSeeder.php @@ -17,8 +17,7 @@ public function run(): void $navbars = Navbar::get(); $subnavbars = Subnavbar::get(); // - $count = 1; - $code = 'mod-' . str_pad(strval($count), 4, "0", STR_PAD_LEFT); + $code = uniqid('mod-', true); // $navbarArray = []; foreach ($navbars as $navbar) { @@ -29,7 +28,7 @@ public function run(): void $subnavbarArray = []; foreach ($subnavbars as $subnavbar) { if ($subnavbar->roles === 'general') { - $subnavbarArray[] = $subnavbar->id; + $subnavbarArray[] = $subnavbar->code; } } Module::create([ diff --git a/database/seeders/System/RoleSeeder.php b/database/seeders/System/RoleSeeder.php index 73f6d18..bbfc5e7 100644 --- a/database/seeders/System/RoleSeeder.php +++ b/database/seeders/System/RoleSeeder.php @@ -29,14 +29,5 @@ public function run(): void 'dashboard_url' => '/dashboard/administration', 'is_landing' => 1 ]); - - $count += 1; - Role::create([ - 'code' => 'RLS-' . date("ymd") . '-' . str_pad(strval($count), 4, "0", STR_PAD_LEFT), - 'name' => 'general', - 'description' => 'General Setting', - 'dashboard_url' => '/dashboard/general', - 'is_landing' => 0 - ]); } } diff --git a/database/seeders/System/Subnavbar/AdministrationSubnavbarSeeder.php b/database/seeders/System/Subnavbar/AdministrationSubnavbarSeeder.php index ae6517f..5f441d7 100644 --- a/database/seeders/System/Subnavbar/AdministrationSubnavbarSeeder.php +++ b/database/seeders/System/Subnavbar/AdministrationSubnavbarSeeder.php @@ -12,11 +12,13 @@ class AdministrationSubnavbarSeeder extends Seeder */ public function run(): void { - Subnavbar::create([ + $sub = Subnavbar::create([ 'navbar_id' => '3', 'name' => 'Maintenance Mode', 'url' => '/administration/maintenance', 'roles' => 'general' ]); + $code = explode("/", $sub->url)[2]; + $sub->update(['code' => $code]); } } diff --git a/database/seeders/System/Subnavbar/MasterSubnavbarSeeder.php b/database/seeders/System/Subnavbar/MasterSubnavbarSeeder.php index 7898514..33a34a9 100644 --- a/database/seeders/System/Subnavbar/MasterSubnavbarSeeder.php +++ b/database/seeders/System/Subnavbar/MasterSubnavbarSeeder.php @@ -12,11 +12,13 @@ class MasterSubnavbarSeeder extends Seeder */ public function run(): void { - Subnavbar::create([ + $sub = Subnavbar::create([ 'navbar_id' => '1', 'name' => 'Pengguna', 'url' => '/master/user', 'roles' => 'general' ]); + $code = explode("/", $sub->url)[2]; + $sub->update(['code' => $code]); } } diff --git a/database/seeders/System/Subnavbar/ReportSubnavbarSeeder.php b/database/seeders/System/Subnavbar/ReportSubnavbarSeeder.php index b553901..b34cc75 100644 --- a/database/seeders/System/Subnavbar/ReportSubnavbarSeeder.php +++ b/database/seeders/System/Subnavbar/ReportSubnavbarSeeder.php @@ -12,11 +12,22 @@ class ReportSubnavbarSeeder extends Seeder */ public function run(): void { - Subnavbar::create([ + $sub = Subnavbar::create([ 'navbar_id' => '4', 'name' => 'Riwayat Aktivitas', 'url' => '/report/activity-log', 'roles' => 'general' ]); + $code = explode("/", $sub->url)[2]; + $sub->update(['code' => $code]); + + $sub = Subnavbar::create([ + 'navbar_id' => '4', + 'name' => 'Riwayat Error', + 'url' => '/report/error-log', + 'roles' => 'general' + ]); + $code = explode("/", $sub->url)[2]; + $sub->update(['code' => $code]); } } diff --git a/database/seeders/System/Subnavbar/SettingSubnavbarSeeder.php b/database/seeders/System/Subnavbar/SettingSubnavbarSeeder.php index 452c122..7e57535 100644 --- a/database/seeders/System/Subnavbar/SettingSubnavbarSeeder.php +++ b/database/seeders/System/Subnavbar/SettingSubnavbarSeeder.php @@ -12,18 +12,22 @@ class SettingSubnavbarSeeder extends Seeder */ public function run(): void { - Subnavbar::create([ + $sub = Subnavbar::create([ 'navbar_id' => '2', 'name' => 'Informasi Institusi', 'url' => '/setting/institution', 'roles' => 'general' ]); + $code = explode("/", $sub->url)[2]; + $sub->update(['code' => $code]); - Subnavbar::create([ + $sub = Subnavbar::create([ 'navbar_id' => '2', 'name' => 'Custom Module', 'url' => '/setting/custom-module', 'roles' => 'general' ]); + $code = explode("/", $sub->url)[2]; + $sub->update(['code' => $code]); } } diff --git a/resources/js/pages/report/error-log.js b/resources/js/pages/report/error-log.js new file mode 100644 index 0000000..6ee1522 --- /dev/null +++ b/resources/js/pages/report/error-log.js @@ -0,0 +1,68 @@ +const url = '/report/api/error-log'; +const itemList = $("#item-list"); +const errorTypeArray = { + 'INFO': 'info', + 'EMERGENCY': 'danger', + 'CRITICAL': 'danger', + 'ALERT': 'warning', + 'ERROR': 'danger', + 'WARNING': 'warning', + 'NOTICE': 'info', + 'DEBUG': 'info', +}; + +getDataLog(url); + +function getDataLog(url) { + $.get(url, (response) => { + if (response && response.success) { + itemList.html(response.data.logs.map(createLogRow).join('')); + $("#item-list-search").show(); + } else { + itemList.html(createEmptyRow()); + $("#item-list-search").hide(); + } + }).fail((xhr, status, error) => console.error('Error:', status, error)); +} + +function createLogRow(log) { + return ` + + ${log.timestamp} + ${log.env} + + ${log.type} + + ${log.message} + + `; +} + +function createEmptyRow() { + return ` + + Tidak ada data + + `; +} + +$('select[name="date-log"]').select2({ + theme: 'bootstrap4', + placeholder: 'Pilih Tanggal Log', + allowClear: true, + ajax: { + url, + dataType: 'json', + delay: 250, + processResults: (response) => ({ + results: response.data.available_log_dates.map(date => ({ + id: date, + text: date + })) + }), + cache: true + } +}); + +$('select[name="date-log"]').on('change', ({ target: { value: date } }) => getDataLog(url + (date ? `?date=${date}` : ''))); + diff --git a/resources/views/_layout/nav.blade.php b/resources/views/_layout/nav.blade.php index 4ca1348..7dcc7c9 100644 --- a/resources/views/_layout/nav.blade.php +++ b/resources/views/_layout/nav.blade.php @@ -67,7 +67,7 @@