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.

WBOY
Release: 2016-08-10 09:07:15
Original
1642 people have browsed it

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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>
Copy after login
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template