Why am I getting this error?
Routes:
Route::group(['prefix'=>'admin','middleware'=>'auth'],function(){
Route::get('/',['uses'=>'Admin\IndexController@index','as'=>'adminIndex']);
Route::resource('/products','Admin\ProductController');
});
Form:
{!! Form::open(['url' => route('admin.products.edit',['products'=>$product->id]),'class'=>'form-horizontal','method'=>'POST']) !!}
{{ method_field('EDIT')}}
{!! Form::button('Edit', ['id'=>'submit','type'=>'submit']) !!}
{!! Form::close() !!}
Also, when I'm trying to get list of routes by typing php artisan route:list, I'm getting error:
[Symfony\Component\HttpKernel\Exception\HttpException]
What's the problem?
I think your resource under admin prefix does not take the admin
prefix. So you still have to use it without admin prefix. Besides, you are using 'url' instead of 'route'.
{!! Form::open(['url' => '/admin/products/'.$product->id.'/edit'),'class'=>'form-horizontal','method'=>'POST']) !!}
If you want to keep using route
{!! Form::open(['route' => ['products.edit', 'products'=>$product->id], 'class'=>'form-horizontal','method'=>'POST']) !!}
If you are tryint to update instead
{!! Form::model($product, ['method' => 'PATCH', 'route' => ['products.update', $product->id], 'class' => 'form-horizontal' ]) !!}
Since edit method uses GET, change your code to:
{!! Form::open(['route' => ['admin.products.edit', $product->id], 'class' => 'form-horizontal', 'method' => 'GET']) !!}
{!! Form::submit('Edit', ['id' => 'submit']) !!}
{!! Form::close() !!}
Also, since it's GET, you can use simple link:
<a href="{{ route('admin.products.edit', $product->id) }}">
<button class="btn" id="submit">Edit</button>
</a>
look down should be use route 'as'=>'admin.products.edit' and get id also redirect to controller function edit products
Route::group(['prefix'=>'admin','middleware'=>'auth'],function(){
Route::get('/edit/{id}/product',
[
'uses'=>'Admin\IndexController@index',
'as'=>'admin.products.edit'
]);
Route::resource('/products','Admin\ProductController');
});