I am new to Laravel and follow a super-basic tutorial. However, the tutorial did not have a record editing section, which I am trying to expand.
Route:
Route::controller('admin/products', 'ProductsController');
Controller:
class ProductsController extends BaseController
{
public function getUpdate($id)
{
$product = Product::find($id);
if ($product) {
$product->title = Input::get('title');
$product->save();
return Redirect::to('admin/products/index')->with('message', 'Product Updated');
}
return Redirect::to('admin/products/index')->with('message', 'Invalid Product');
}
..ECT...
I understand that the controller is requesting an identifier, but I cannot figure out how to pass the product identifier to it when the form is submitted / received.
the form:
{{Form::open(array("url"=>"admin/products/update",'method' => 'get', 'files'=>true))}}
<ul>
<li>
{{ Form::label('title', 'Title:') }}
{{ Form::text('title') }}
{{ Form::hidden('id', $product->id) }}
..ECT...
{{ Form::close() }}
my initial idea was to pass in the product id as a URL, for example:
{{Form::open(array("url"=>"admin/products/update/{{product->id}}", 'files'=>true))}}
But no luck with that.
The error I get is:
Missing argument 1 for ProductsController::postUpdate()
I wonder if I type directly into the url:
http:
This works, and the element with id 3 is changed.
So can someone help and tell me how to pass the id with the form?
Many thanks
source
share