Reputation: 704
I have a route that takes me to my item page.
Route::get('/items/{item}', 'ItemsController@show');
In this page I have a form if the form is not filled out properly it will redirect to the forms method which currently is
action="/items"
How can I access that same {item} id number while in the blade?
Edit: Here is the Controller code
public function index()
{
$item = Post::get();
$price = $item->price;
return view('item');
}
public function show(Item $item)
{
return view('item', compact('item'));
}
Upvotes: 0
Views: 25
Reputation: 50767
You're returning compact('item')
which gives you $item
in your blade template.
You can use it within blade syntax, just like this:
{{ $item->id }}
Upvotes: 2