A fix for "Target class [web] does not exist." and an update to the Demo to work with custom url_prefix and middlewares #1026
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the change:
Issue 1:
if (config('lfm.use_package_routes')) is true then a route with prefix
'filemanger'and middleware['web','auth’]is appliedin this case if the user doesn’t have
webmiddleware he will getTarget class [web] does not exist.error.The suggested solution:
this can be fixed by adding
middlewaresarray in config, if present it will take the values or fallback to['web','auth’]making the prefix variable is also preferable by adding
url_prefix, so ifurl_prefixis present in config the route will take that value, else it will fallback tofilemanagerIssue 2:
The demo is using
/filemangerroute, but in case the user creates custom route with prefix different than/filemanger(and sets thelfm.use_package_routesto false) the demo will no longer work because it will not find any route named/filemangerThe suggested solution:
This can be fixed by initializing the variable
route_prefixin the demo view with theurl_prefixvalue from config if present, then fallback to/filemanagerif no value is presentRecap:
Optional
url_prefixandmiddlewaresare added to config file, so in case ofuse_package_routesis true, the route generated will try to getprefixvalue andmiddlewarearray from config file before falling back to static values.Also if the user creates a route with a custom prefix, he can set that prefix in config, so it will be used in the demo without failing if
use_package_routesis false.