ndar0430 said:
what im trying to do is upon submitting the details, the user_id of the submitter will be inserted in the database.
Inserting it into where?
Your code here:
$rfq= $user->rfq_table()->create($request->all());
Inserts everything from the form into the rfq_table, I'm guessing. Is that where you want to store the user_id? If it is, why not insert the user_id at the same time?
whatarewe said:
ndar0430 said:
what im trying to do is upon submitting the details, the user_id of the submitter will be inserted in the database.
Inserting it into where?
Your code here:
$rfq= $user->rfq_table()->create($request->all());
Inserts everything from the form into the rfq_table, I'm guessing. Is that where you want to store the user_id? If it is, why not insert the user_id at the same time?
its actually i copy paste code from a tutorial on youtube..
not really understand what that says.
actually i understand everything aside from the function store.
so maybe there's an alternative code where the user id(the authenticated user who click submit) will be save on the database
ndar0430 said:
not really understand what that says.
actually i understand everything aside from the function store.
so maybe there's an alternative code where the user id(the authenticated user who click submit) will be save on the database
Well, reading the documentation will be a start. But here's what happens.
$rfq= $user->rfq_table()->create($request->all());
saves every field from the form into the rfq_table.There's a bit more to it than that. The rfq_table has a function called create()
written for it that takes the information and inserts it to the database. So look for that function, and it'll be able to tell you exactly how it stores the information in the database. When you can understand that, you'll be able to pull the authenticated user id in the controller and pass it along to create() for it to be stored as well.
https://laracasts.com/ also has lots of videos that'll be able to explain it more in-depth, and probably do a better job than I'm doing right now.
whatarewe said:
ndar0430 said:
not really understand what that says.
actually i understand everything aside from the function store.
so maybe there's an alternative code where the user id(the authenticated user who click submit) will be save on the database
Well, reading the documentation will be a start. But here's what happens.
- user types information into a form
- user clicks submit
- the browser submits information from the form to your controller
$rfq= $user->rfq_table()->create($request->all());
saves every field from the form into the rfq_table.There's a bit more to it than that. The rfq_table has a function called
create()
written for it that takes the information and inserts it to the database. So look for that function, and it'll be able to tell you exactly how it stores the information in the database. When you can understand that, you'll be able to pull the authenticated user id in the controller and pass it along to create() for it to be stored as well.https://laracasts.com/ also has lots of videos that'll be able to explain it more in-depth, and probably do a better job than I'm doing right now.
i now understand what u said but the thing is that i still don't know how to get the current login user ID to be inserted upon submission :( i hope you could help me im stuck here for days, we can do skype. i just really need it badly
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community