Compare commits
2 Commits
45810efa3d
...
db364c5877
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db364c5877 | ||
|
|
cf120c035e |
@@ -6,19 +6,44 @@
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Usermanagement\Models\User;
|
||||
use Spatie\Activitylog\Models\Activity;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class AuditLogsController extends Controller
|
||||
{
|
||||
protected $user;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// Mengatur middleware auth
|
||||
$this->middleware('auth');
|
||||
|
||||
// Mengatur user setelah middleware auth dijalankan
|
||||
$this->middleware(function ($request, $next) {
|
||||
$this->user = Auth::user();
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Check if the authenticated user has the required permission to view audit logs
|
||||
if (is_null($this->user) || !$this->user->can('audit-logs.read')) {
|
||||
abort(403, 'Sorry! You are not allowed to view audit logs.');
|
||||
}
|
||||
|
||||
return view('logs::audit');
|
||||
}
|
||||
|
||||
public function datatable(Request $request)
|
||||
{
|
||||
// Check if the authenticated user has the required permission to view audit logs
|
||||
if (is_null($this->user) || !$this->user->can('audit-logs.read')) {
|
||||
abort(403, 'Sorry! You are not allowed to view audit logs.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = Activity::query();
|
||||
|
||||
@@ -97,6 +122,5 @@
|
||||
'totalCount' => $filteredRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,14 +6,24 @@ use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Jackiedo\LogReader\Exceptions\UnableToRetrieveLogFilesException;
|
||||
use Jackiedo\LogReader\LogReader;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class SystemLogsController extends Controller
|
||||
{
|
||||
protected $reader;
|
||||
protected $user;
|
||||
|
||||
public function __construct(LogReader $reader)
|
||||
{
|
||||
$this->reader = $reader;
|
||||
// Mengatur middleware auth
|
||||
$this->middleware('auth');
|
||||
|
||||
// Mengatur user setelah middleware auth dijalankan
|
||||
$this->middleware(function ($request, $next) {
|
||||
$this->user = Auth::user();
|
||||
return $next($request);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -21,10 +31,20 @@ class SystemLogsController extends Controller
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
// Check if the authenticated user has the required permission to view system logs
|
||||
if (is_null($this->user) || !$this->user->can('system-logs.read')) {
|
||||
abort(403, 'Sorry! You are not allowed to view system logs.');
|
||||
}
|
||||
|
||||
return view('logs::system');
|
||||
}
|
||||
|
||||
public function datatable(Request $request){
|
||||
// Check if the authenticated user has the required permission to view system logs
|
||||
if (is_null($this->user) || !$this->user->can('system-logs.read')) {
|
||||
abort(403, 'Sorry! You are not allowed to view system logs.');
|
||||
}
|
||||
|
||||
$data = collect();
|
||||
$this->reader->setLogPath(storage_path('logs'));
|
||||
try {
|
||||
|
||||
@@ -11,6 +11,8 @@ class LogsDatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// $this->call([]);
|
||||
$this->call([
|
||||
PermissionSeeder::class
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
33
database/seeders/PermissionSeeder.php
Normal file
33
database/seeders/PermissionSeeder.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Logs\Database\Seeders;
|
||||
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Str;
|
||||
use Modules\Usermanagement\Models\PermissionGroup;
|
||||
|
||||
class PermissionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
$data = $this->data();
|
||||
|
||||
foreach ($data as $value) {
|
||||
PermissionGroup::updateOrCreate([
|
||||
'name' => $value['name'],
|
||||
'slug' => Str::slug($value['name'])
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function data()
|
||||
{
|
||||
return [
|
||||
['name' => 'system-logs'],
|
||||
['name' => 'audit-logs'],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="csrf-token" content="{{ csrf_token() }}">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
|
||||
<title>Logs Module - {{ config('app.name', 'Laravel') }}</title>
|
||||
|
||||
<meta name="description" content="{{ $description ?? '' }}">
|
||||
<meta name="keywords" content="{{ $keywords ?? '' }}">
|
||||
<meta name="author" content="{{ $author ?? '' }}">
|
||||
|
||||
<!-- Fonts -->
|
||||
<link rel="preconnect" href="https://fonts.bunny.net">
|
||||
<link href="https://fonts.bunny.net/css?family=figtree:400,500,600&display=swap" rel="stylesheet" />
|
||||
|
||||
{{-- Vite CSS --}}
|
||||
{{-- {{ module_vite('build-logs', 'resources/assets/sass/app.scss') }} --}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@yield('content')
|
||||
|
||||
{{-- Vite JS --}}
|
||||
{{-- {{ module_vite('build-logs', 'resources/assets/js/app.js') }} --}}
|
||||
</body>
|
||||
Reference in New Issue
Block a user