lewis4u
lewis4u

Reputation: 15037

Get model id from route/url

I have a user, event and offer model. A user can make an event and then another user can make an offer for that event. But now I don't know how to get event id in store method for offer

I get error event_id not defined.

When i click on make offer the show view opens for that event and i have the event model in that view...and on that view there is a form to submit offer and i don't know how to get that event id

when i do dd($request->all()); there are only variables from that form

and what i need is the id of that event.

Upvotes: 1

Views: 228

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163768

With store() method you need to add hidden input to the form, for example:

{!! Form::hidden('event_id', $event->id) !!}

And then get the data:

$event_id = $request->event_id;

Upvotes: 2

Related Questions