ARCANEDEV / LogViewer

:page_with_curl: Provides a log viewer for Laravel
MIT License
2.37k stars 335 forks source link

route prefix with parameter #421

Closed omersavas26 closed 7 months ago

omersavas26 commented 2 years ago

Description:

If you use a parameter like "token" in the route prefix, some errors occur. (For example prefix = '{token}/log-viewer')

first error: Missing required parameter for [Route: log-viewer::dashboard] [URI: {token}/log-viewer] [Missing parameter: token]. To solve this, i put in middleware: \URL::defaults([ 'token' => $token ]);

second error: 3 urls fall into 404 error.

http://.../gG0OEYHRmd1/log-viewer/logs/2022-07-31 http://.../gG0OEYHRmd1/log-viewer/logs/2022-07-31/alert http://.../gG0OEYHRmd1/log-viewer/logs/2022-07-31/all/search

Because while the show, showById and search methods in "Arcanedev\LogViewer\Http\Controllers\LogViewerController" are waiting for $data, the $token parameter comes. To solve this I applied the following replacements:

public function show(Request $request, ...$args)
{
    $date = last($args);
    ...
}  

public function showByLevel(Request $request, ...$args)
{
    $date = $args[count($args)-2];
    $level = last($args);
    ...
}  

public function search(Request $request, ...$args)
{
    $date = $args[count($args)-2];
    $level = last($args);
    ...
}  

If you want, I can make a pull request to fix this issue. Respects.