Home >Backend Development >PHP Tutorial >After laravel5.2 defines resource routing, there is a problem in parsing the routing in the blade template.

After laravel5.2 defines resource routing, there is a problem in parsing the routing in the blade template.

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-08-10 09:07:151699browse

In the process of using laravel5.2, a small problem occurred. Please tell me.

I defined a resource route and stored the names of the resource routes in the database. Now after searching and deleting through the database, I get the following results:

<code class="php">
    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)    

  </code>

Next in the template, I output all the URLs corresponding to all the route names in the above array

<code class="php">
    @foreach($menulist as $menu)
        {{ route($menu->route) }}
    @endforeach
</code>

But an error occurred:

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

If you simply use {{ route('menu.index') }}, there will be no error. May I ask what the problem is?

Reply content:

In the process of using laravel5.2, a small problem occurred. Please tell me.

I defined a resource route and stored the names of the resource routes in the database. Now after searching and deleting through the database, I get the following results:

<code class="php">
    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)    

  </code>

Next in the template, I output all the URLs corresponding to all the route names in the above array

<code class="php">
    @foreach($menulist as $menu)
        {{ route($menu->route) }}
    @endforeach
</code>

But an error occurred:

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

If you simply use {{ route('menu.index') }}, there will be no error. May I ask what the problem is?

What you read from the database at this time is only the string of the object, not an object. It needs to be converted into an object before it can be executed

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn