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?
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