i want to do seller can edit and update product
this is ProductController
public function edit($id)
{
$product = Product::find($id);
return view('product.edit', compact('product'));
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$product = Product::find($id);
$product-> title = $request-> title;
$product-> description = $request-> description;
$product-> price = $request-> price;
if($request->hasFile('image')){
$file = $request-> file('image');
$filename = time().'.'.$file-> getClientOriginalExtension();
$location = public_path('/images');
$file-> move($location, $filename);
$oldImage = $product->image;
\Storage::delete($oldImage);
$product-> image= $filename;
}
$product-> save();
return back();
}
this is edit.blade.php
<form action="{{route('product.update', $product->id)}}" method="post" enctype="multipart/form-data">
{{csrf_field()}}
{{method_field('put')}}
[...]
<button type="submit" class="btn btn-success">Submit</button>
this is web.php
Route::get('/index', 'ProductController@index');//seller view all product
Route::get('/create', 'ProductController@create'); //seller create new product
Route::post('','ProductController@store')->name('product.store'); //store in database
Route::get('/edit/{id}','ProductController@edit'); // seller edit post
Route::post('','ProductController@update')->name('product.update'); //seller update
when i click submit button for update The PUT method is not supported for this route. Supported methods: GET, HEAD, POST. show up
how i can fix it? PLEASE HELP