This is the problem. Argument #1 ($slider) must be of type App\Models\Slider, string given .
You are passing a string to a method, when it expects a instance of the Slider model class.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have PHP 8, Laravel 9 with Inertia (Vue 3). I have a resource controller inside a grouped route. See the code below:
Route::group([
'prefix' => '{locale?}',
'where' => ['locale' => '[a-zA-Z]{2}'],
'middleware' => 'set-locale',
], function () {
Route::resource('/sliders', SliderManagement::class);
});
I created a link in a vue page to visit sliders.show. Check the vue code below:
<a v-for="slider in sliders" :key="slider.id" :href="route('sliders.show', {slider: slider.id, locale: locale})">Go to slider {{ slider.id }}</a>
When I visit the link, I am getting the following error:
App\Http\Controllers\Admin\SliderManagement::show(): Argument #1 ($slider) must be of type App\Models\Slider, string given, called in /home/atif/Desktop/Freelancing/Sebastian Projects/98goal.com/98goal.com/vendor/laravel/framework/src/Illuminate/Routing/Controller.php on line 54
The code related to the show method is as follows:
public function show(Slider $slider) {
return Inertia::render('Admin/Slider/Show', ['slider' => $slider]);
}
@atif-bashir-1998 Your routes are defined with the locale variable first, the slider variable second. Note that the docs say:
Route parameters are injected into route callbacks / controllers based on their order - the names of the route callback / controller arguments do not matter.
That means when you pass the slider ID first and the locale second, it will interpret the slider ID as the locale string and the locale as the slider ID. Since the slider ID won’t match your regex for locale strings, it is ignored.
I think it should work if you switch the order of the route parameters in the link to {locale: locale, slider: slider.id} (or indeed just [locale, slider.id]?).
Please or to participate in this conversation.