I'm getting this error because of a long variable name. How do I override the variable name?
I would very much like to keep the resource name.
My route is:
Route::resource(
    'computer-software-version-installation',
    'Web\Model\ComputerSoftwareVersionInstallationController'
);
                Here is what I did to fix:
    Route::resource(
        'computer-software-version-installation',
        'Web\Model\ComputerSoftwareVersionInstallationController',
        ['parameters' => [
            'computer-software-version-installation' => 'installation'
        ]]
    );
Why is this necessary?
For Laravel 5.3, here is the extended answer:
The Illuminate\Routing\Router resource method creates a new ResourceRegistrar to register the routes.  This method as an $options parameter.
The Illuminate\Routing\ResourceRegistrar register method will set the parameters attribute to the $options['parameters'] value, then calls getResourceWildcard to set the $base variable value using the last part of the $name as the input parameter.
The Illuminate\Routing\ResourceRegistrar getResourceWildcard method will look through the parameters to see if there is a value, and use it if there is.  Otherwise it goes through some gyrations to make a string.
So if we pass in a 'parameters' array with a key that matches the route name, and the value equal to the place-holder name, we can avoid the error.
The issue with getResourceWildcard was mentioned here:
https://github.com/laravel/framework/issues/1001#issuecomment-134887584
but seemed to be rebutted here as a Symphony issue?
https://github.com/laravel/framework/issues/1001#issuecomment-212518768
Hopefully, this answer helps someone else with a work around. But it has not been extensively tested, so it may still have problems.
Here's a relevant discussion. The issue seems to be more directly tied to Sympfony.
https://github.com/laravel/framework/issues/1001
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With