How to select some columns only in Laravel relationship?
<p>I have the following database structure:</p>

<ul>
<li><p>user</p>

<ul>
<li>id</li>
<li>name</li>
</ul></li>
<li><p>post</p>

<ul>
<li>id</li>
<li>user_id</li>
<li>title</li>
<li>content</li>
</ul></li>
</ul>

<p>So I creating the relationship function in my model:</p>

<pre><code>class User extends Model {
   public function post()
   {
      return $this-&gt;hasMany(Post::class);
   }
}
</code></pre>

<p>If I execute <code>$user-&gt;post</code> will returning complete post objects.</p>

<p>How to can I get only posts ID?</p>