After laravel5.2 defines the resource route, a problem occurs when parsing the route in the blade template.

Source: Internet
Author: User
A small problem occurred while using laravel5.2. I have defined a resource route and saved the resource route name to the database. now, after searching and deleting the database, the following result is displayed: {code ...} next, in the template, I put the above array... A small problem occurred while using laravel5.2.

I have defined a resource route and saved the resource route name to the database. now, after searching and deleting the database, the following results are obtained:

    array (size=6)      0 =>         object(stdClass)[221]          public 'id' => int 10          public 'route' => string 'menu.create' (length=11)      1 =>         object(stdClass)[222]          public 'id' => int 11          public 'route' => string 'menu.index ' (length=11)      

Next, in the template, I output all the URLs corresponding to all the routing names in the preceding array.

    @foreach($menulist as $menu)        {{ route($menu->route) }}    @endforeach

But an error occurs:

ErrorException in UrlGenerator. php line 314:
Route [menu. index] not defined.

If you simply use {route ('menu. index')}, no error occurs. Where is the problem?

Reply content:

A small problem occurred while using laravel5.2.

I have defined a resource route and saved the resource route name to the database. now, after searching and deleting the database, the following results are obtained:

    array (size=6)      0 =>         object(stdClass)[221]          public 'id' => int 10          public 'route' => string 'menu.create' (length=11)      1 =>         object(stdClass)[222]          public 'id' => int 11          public 'route' => string 'menu.index ' (length=11)      

Next, in the template, I output all the URLs corresponding to all the routing names in the preceding array.

    @foreach($menulist as $menu)        {{ route($menu->route) }}    @endforeach

But an error occurs:

ErrorException in UrlGenerator. php line 314:
Route [menu. index] not defined.

If you simply use {route ('menu. index')}, no error occurs. Where is the problem?

What you read from the database at this time is only the object string, not an object. you need to convert it into an object before you can execute

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.