I am not able to update a particular column of my database. In my database there is a "conditions" column which has a default value of "pending". I want to update this column with value "accept", but I am unable to do so.
My routes.php
Route::get('accept/{id}',array(
'as'=>'accept-product',
'uses'=>'GoodsController@updateProduct
));
My controller:
public function updateProduct($id)
{
$product = Products::findOrFail($id);
$product->conditions = 'accept';
$product->save();
}
My view:
@foreach($product as $productAccept)
<a href="{{URL::route('accept-product')}}/{!! $productAccept->id !!} ">Accept</a>
@endforeach
When I clicked accept button, the url is like this
http://localhost/project/public/accept/{id}
Which I want like this:
http://localhost/project/public/accept/7
I mean I am unable to replace {id}
to integer like 7
,8
etc.
Is something wrong in my routes
?
Your defined route expects one extra parameter - id. You need to pass the product id in the route function as extra parameter like this:
<a href="{{URL::route('accept-product', ['id' => $productAccept->id])}}">Accept</a>
use url as that
<a href="{!! URL::to('accept/$productAccept->id') !!}">Accept</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With