I got an error : Route [admin/news] not defined I try to use @component in my create.blade.php
In my Controller I declare variable
public $route = 'admin/news' ;
In web.php
Route::post('admin/news/create', 'Admin\NewsController@store');
Route::resource('admin/news', 'Admin\NewsController');
In my html this return right Url
<a class="btn btn-success" href="{{ asset($route.'/create') }}">add</a>
<a class="btn btn-success" href="{{ route('news.create') }}">add</a>
I check my route by using php artisan r:l
It has a news.create
I try to use other routes both of these work fine not sure what's wrong with my create route
route('news.edit',$t->id)
route('news.destroy',$t->id)
the problem is in my create.blade.php I try to use @component by this
@component('layouts.submitform',
['id'=>'create','method'=> isset($edit) ? 'PUT' : 'POST' ,'action'=> isset($data->id) ? asset($route.'/'.$data->id) : route($route)]
)
You have $route
set to admin/news
. You say you want to go to the create page. You then say that the route is named news.create
. So use news.create
as the name when referencing it with the helper. Set $route
to news.create
.
You seem to want to use a URI and a route name. You have to decide which one you are going for.