0

I made contact form in Laravel. some of input field are just normal input field. And rest of them are JS generate data which are 'product', 'quantity' and 'price'. I can store ONLY normal input field data.

Here is my dd() image.

enter image description here

And this is my blade file.

<select id="product" name="product" onchange="caliculate()"></select>
<input id="v_product" type="hidden" name="product">

Controller

//Store data in database
Contact::create($request->all());

Could you teach me how to store product, quantity and price data into Mysql please?

2
  • Use different name attributes for your fields Commented Aug 12, 2020 at 6:08
  • Thank you for helping me. Sorry I'm still don't get it. Could you teach me code please? Commented Aug 12, 2020 at 6:19

1 Answer 1

2

If you want to exclude the other fields when getting request parameters, you can do the following:

Contact::create($request->only(['product', 'quantity', 'price']));
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for helping me. I would like to store all data. but somehow I can't store 'product', 'quantity', 'price' .
@bluetail Are they added to fillable array in Contact model?
OMG! I totally forgot that! Sorry!!! It worked! Thank you so much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.