-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from kangketikonlen/061124-024117
[06-11-2024 02:42] 061124-024117 - Request merge 061124-024117 to stable branch
- Loading branch information
Showing
49 changed files
with
524 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Report; | ||
|
||
use Illuminate\Http\Request; | ||
use App\Models\System\ActivityLog; | ||
use App\Http\Controllers\Controller; | ||
use Illuminate\View\View; | ||
|
||
class ActivityLogController extends Controller | ||
{ | ||
protected string $url = "/report/activity-log"; | ||
|
||
public function index(Request $request): View | ||
{ | ||
$activityLogs = ActivityLog::orderBy('id', 'desc'); | ||
$dateStart = $request->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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Report; | ||
|
||
use App\Http\Controllers\Controller; | ||
use Illuminate\Http\Request; | ||
|
||
class ErrorLogController extends Controller | ||
{ | ||
public function index(Request $request) | ||
{ | ||
return view('pages.report.error-log.index'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace App\Http\Middleware; | ||
|
||
use Closure; | ||
use Illuminate\Http\Request; | ||
use App\Models\System\ActivityLog; | ||
use Illuminate\Support\Facades\Auth; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class ActivityLogMiddleware | ||
{ | ||
/** | ||
* Handle an incoming request. | ||
* | ||
* @param \Closure(\Illuminate\Http\Request): (\Symfony\Component\HttpFoundation\Response) $next | ||
*/ | ||
public function handle(Request $request, Closure $next): Response | ||
{ | ||
$auth = Auth::check(); | ||
$path = $request->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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace App\Models\System; | ||
|
||
use Illuminate\Support\Facades\Auth; | ||
use Illuminate\Database\Eloquent\Model; | ||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
|
||
class ActivityLog extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected static function boot() | ||
{ | ||
parent::boot(); | ||
|
||
static::creating(function ($model) { | ||
$model->created_by = Auth::check() ? session('name') : "System"; | ||
}); | ||
|
||
static::updating(function ($model) { | ||
$model->updated_by = Auth::check() ? session('name') : null; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.