Framework Error
Argument 1 passed to Illuminate\Routing\Route::current() must be of the type string, array given, called in /var/www/html/app/Http/Kernel.php on line 111
What This Error Means
This error occurs when a Laravel application is trying to access the current route, but it expects a string as an argument, whereas an array is being passed instead.
Why It Happens
This error typically happens when there's a mismatch between the expected data type and the actual data type being passed to a Laravel function. In this case, the function expects a string (e.g., route name), but an array (e.g., route parameters) is being passed instead.
How to Fix It
- 1To fix this error, you need to ensure that the correct data type is being passed to the function. Check the function call and the data being passed to it. In this case, you can pass the correct route name to the function. For example, instead of passing an array of route parameters, pass the string name of the route.
- 2// Before (broken code)
- 3Route::current([], ['id' => 1]);
- 4// After (fixed code)
- 5Route::current('user.show');
Example Code Solution
use Illuminate\Routing\Route;
Route::current([], ['id' => 1]);use Illuminate\Routing\Route;
Route::current('user.show');Fix for Argument 1 passed to Illuminate\Routing\Route::current() must be of the type string, array given, called in /var/www/html/app/Http/Kernel.php on line 111
Browse Related Clusters
Related PHP Errors
Trying to access array offset on value of type null in /var/www/html/d
Notice: Undefined variable: database_connection in /var/www/html/datab
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Du
The controller method 'render' is not defined in the controller 'App\C
Related PHP Blog Articles
Have a different error? Get an instant explanation.
Explain Another Error