title: How to create endpoint to post data and the response is nested array in Laravel 8
body: <p>I'm a beginner in Laravel and I would like to make API with the response like this</p>
  <pre><code>elements: [
          {
            title:
              &quot;Please indicate if you agree or disagree with the following statements&quot;,
            question: [
              {
                value: &quot;affordable&quot;,
                text: &quot;Product is affordable&quot;,
              },
              {
                value: &quot;does what it claims&quot;,
                text: &quot;Product does what it claims&quot;,
              },
              {
                value: &quot;better then others&quot;,
                text: &quot;Product is better than other products on the market&quot;,
              },
              {
                value: &quot;easy to use&quot;,
                text: &quot;Product is easy to use&quot;,
              },
            ],
          },
        ],
  </code></pre>
  <p>here's code in my migration database :</p>
  <pre><code>Schema::create('question_surveys', function (Blueprint $table) {
              $table-&gt;id('question_survey_id');
              $table-&gt;string('title');
              $table-&gt;json('question');
              $table-&gt;timestamps();
          });
  </code></pre>
  <p>and in my controller, for store the data that I have created, I tried this</p>
  <pre><code>$validation = $request-&gt;validation([
              'title' =&gt; 'required|string',
              'question' =&gt; 'required|json',
              
          ]);
  
          try {
              $response = QuestionSurvey::create($validation);
              return response()-&gt;json([
                  'success' =&gt; true,
                  'message' =&gt; 'Survey Question Successfully Created',
                  'data' =&gt; $response,
                  'code' =&gt; 200
              ], 200);
          } catch (\Exception $e) {
              return response()-&gt;json([
                  'message' =&gt; 'Something wrong, content was not created successfully',
                  'errors' =&gt; $e-&gt;getMessage()
              ]);
          }
  </code></pre>
  <p>I tried to post data in postman, the code return 200 but not successfully created. I'm confused what should I do and what the exactly keyword I should search on google to solve this problem. I'm very thankful if you can help me to solve this problem..</p>