Support the ongoing development of Laravel.io →
Requests Database Forms
Last updated 2 years ago.
0

Don't know how your database is managed, but i'll surely create a separate table , which will have the following columns (In relationship , we create a middle tier ,which holds keys of 2 or more tables).

dynamicData Table ;)

table_id timestamps() - Created / Updated question_id - from Questions Table
comment_id - from Comment Table ratings_id - from Ratings Table user_id - If using user authentication ip/token - if collecting that info

I personally ensure proper relationship in tables via sql, but you can always create proper relationships in database design.

0

I do have a model for ratings, questions and comments. So for each model I have a database table. When I store the request

This is what I get back as request.

object(Illuminate\Http\Request)[40]
  ...
public 'request' => 
    object(Symfony\Component\HttpFoundation\ParameterBag)[41]
      protected 'parameters' => 
        array (size=30)
          '_token' => string 'MgMX95LUb3cwarkDI38UzxDKmnuzwgwF7XU5uZSK' (length=40)
          'professional' => string '1' (length=1)
          'questionId2' => string '5' (length=1)
          'commentId2' => string 'comment 1' (length=9)
          'questionId4' => string '3' (length=1)
          'commentId4' => string 'comment 2' (length=9)
          'questionId5' => string '8' (length=1)
          'commentId5' => string 'comment 3' (length=9)
          'questionId6' => string '8' (length=1)
          'commentId6' => string 'comment 4' (length=9)
          'questionId13' => string '8' (length=1)
          'commentId13' => string 'comment 5' (length=9)
          'questionId1' => string '4' (length=1)
          'commentId1' => string 'comment 6' (length=9)
          'questionId7' => string '6' (length=1)
          'commentId7' => string 'comment 7' (length=9)
          'questionId8' => string '7' (length=1)
          'commentId8' => string 'comment 8' (length=9)
          'questionId9' => string '8' (length=1)
          'commentId9' => string 'comment 9' (length=9)
          'questionId3' => string '6' (length=1)
          'commentId3' => string 'comment 10' (length=10)
          'questionId10' => string '10' (length=2)
          'commentId10' => string 'comment 11' (length=10)
          'questionId11' => string '7' (length=1)
          'commentId11' => string 'comment 12' (length=10)
          'questionId12' => string '5' (length=1)
          'commentId12' => string 'comment 13' (length=10)
          'questionId16' => string '6' (length=1)
          'commentId16' => string 'comment 14' (length=10)
...

This contain all the data I need to store. The questionId with the rating and the commentId which refer to the questionId and the value.

Last updated 8 years ago.
0

you can use the previous example as is, with addition of one more table, which holds an id of "RESULT" and allows you to query the data easily. (Don't forget to add up user_id with RESULT).

dynamicData Table ;)

  • table_id timestamps() - Created / Updated (Dynamic Table Row ID)
  • question_id - from Questions Table
  • comment_id - from Comment Table
  • ratings_id - from Ratings Table
  • user_id - If using user authentication ip/token - if collecting that info
  • result_id - (result ID, this id will be same for all 30 questions and will be used multiple times in dynamicData table to hold proper information)
Last updated 8 years ago.
0

Thanks! I have a slightly modified version of your example but works fine. Thank you again!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.