Crud: [Bug] Route parameter problem after upgrade from laravel 5.8 to laravel 6.0 with backpack crud 3.6.33

Created on 5 Jun 2020  路  5Comments  路  Source: Laravel-Backpack/CRUD

Bug report

Hello,

I'm try to upgrade from laravel 5.8 to laravel 6 and stay with backpack version 3.6.33 (our project is large and the transition to backpack 4 is complex :wink: ) and I'have strange issue

Now, when I use

route ('crud.opportunity.edit', ['id' => 'x'])

I have the following error:

_Missing required parameters for [Route: crud.opportunity.edit] [URI: opportunity / {opportunity} / edit]_

But with

route ('crud.opportunity.edit', ['opportunity' => 'x'])

That's work fine

Do you have some idea why the required parameter name have changed?

  • before (laravel 5.8): {id}
  • after (laravel 6): {opportunity}

Thanks for your help

Backpack, Laravel, PHP, DB version

  • PHP 7.2.28-3+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Feb 23 2020 07:23:01) ( NTS )
  • backpack/base 1.1.13
  • backpack/crud 3.6.33
  • backpack/generators 1.2.7
  • laravel/framework v6.18.18
  • Database : PostgreSQL
Bug

All 5 comments

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps _a lot_ in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication channels:

  • Bug Reports, Feature Requests - Github Issues (here);
  • Quick help (_How do I do X_) - Gitter Chatroom;
  • Long questions (_I have done X and Y and it won't do Z wtf_) - Stackoverflow, using the backpack-for-laravel tag;
  • Showing off something you've made, asking for opinion on Backpack/Laravel matters - Reddit;

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome _awesome_ community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

--
Justin Case
The Backpack Robot

Hello @yvesnetalis

Indeed I allways used the parameter name in route() helper as the same name in route, and from laravel documentation that's how it's supposed to work: https://laravel.com/docs/7.x/routing#required-parameters

This is not something we can help you with, nor a Backpack bug. You might want to look for Laravel upgrade guide for references about it or whatever you can find, but my best advise to you is just to fix it. I think that's the way it's supposed to work.

Best,
Pedro

Hello @pxpm

Thank you to your answer

I had read Laravel's upgrade page but it didn't help much. I have not found what has changed in Laravel's code.

But I found how to fix this in backpack :smile:

In crud/src/CrudRouter.php, I added the following code on $options_with_defaut_route_names array

'parameters' => [
    $this->name => 'id',
]

Capture du 2020-06-05 11-59-08

Problem solved !

Have a good day,
Yves

(https://laravel.com/docs/6.x/controllers#restful-naming-resource-route-parameters)

Well done @yvesnetalis very nice and clean solution.

Thank you very much for making it public, it might help someone that struggles with same problem.

Best,
Pedro

Was this page helpful?
0 / 5 - 0 ratings