title: Laravel API Customizing associated columns
body: <p>I have an api source that I combined in related tables. I have customized the objects, but I cannot customize the associated data in it. How do I do this?</p>
  <p>Previous Output:<br></p>
  <pre><code>{
      &quot;id&quot;: 1,
      &quot;user_id&quot;: 3,
      &quot;image&quot;: &quot;https://localhost/800/400/cats/varem/?20215&quot;,
      &quot;description&quot;: &quot;Omnis eius corporis incidunt illo dolor et est odio. Et fuga hic id. Velit voluptas tempore quas voluptas iusto. Quia rerum quibusdam consectetur distinctio vero. Nihil et sed reiciendis sequi. Possimus facere ducimus provident est. Qui ut rerum ab ullam sequi est. In placeat nesciunt odio numquam iure.&quot;,
      &quot;created_at&quot;: &quot;2017-09-18T10:51:17.000000Z&quot;,
      &quot;updated_at&quot;: &quot;2020-12-25T08:55:40.000000Z&quot;,
      &quot;likes&quot;: [
        {
          &quot;id&quot;: 7,
          &quot;user_id&quot;: 10,
          &quot;post_id&quot;: 1,
          &quot;created_at&quot;: &quot;1970-03-31T14:17:28.000000Z&quot;,
          &quot;updated_at&quot;: &quot;2020-12-25T08:55:40.000000Z&quot;
        }
      ]
    }
  </code></pre>
  <p>Function:
  <br></p>
  <pre><code>public function like_show($id) {
           return Posts::selectRaw('id as post_id, user_id, image as post_image, description as post_description, created_at')
               -&gt;with('likes')
               -&gt;where('user_id', '=', $id)
               -&gt;get();
      }
  </code></pre>
  <p>Next Output:</p>
  <pre><code>{
      &quot;post_id&quot;: 1,
      &quot;user_id&quot;: 3,
      &quot;post_image&quot;: &quot;https://localhost/800/400/cats/varem/?20215&quot;,
      &quot;post_description&quot;: &quot;Omnis eius corporis incidunt illo dolor et est odio. Et fuga hic id. Velit voluptas tempore quas voluptas iusto. Quia rerum quibusdam consectetur distinctio vero. Nihil et sed reiciendis sequi. Possimus facere ducimus provident est. Qui ut rerum ab ullam sequi est. In placeat nesciunt odio numquam iure.&quot;,
      &quot;created_at&quot;: &quot;2017-09-18T10:51:17.000000Z&quot;,
      &quot;likes&quot;: [
        
      ]
    }
  </code></pre>
  <p>Output I want:</p>
  <pre><code>{
      &quot;post_id&quot;: 1,
      &quot;user_id&quot;: 3,
      &quot;post_image&quot;: &quot;https://localhost/800/400/cats/varem/?20215&quot;,
      &quot;post_description&quot;: &quot;Omnis eius corporis incidunt illo dolor et est odio. Et fuga hic id. Velit voluptas tempore quas voluptas iusto. Quia rerum quibusdam consectetur distinctio vero. Nihil et sed reiciendis sequi. Possimus facere ducimus provident est. Qui ut rerum ab ullam sequi est. In placeat nesciunt odio numquam iure.&quot;,
      &quot;created_at&quot;: &quot;2017-09-18T10:51:17.000000Z&quot;,
      &quot;likes&quot;: [
        &quot;like_id&quot;: 3,
        &quot;user_id&quot;: 10,
        &quot;post_id&quot;: 1,
      ]
    }
  </code></pre>