title: Laravel Eloquent - auto-numbering on has many relationship
body: <p>I'm very much a beginner when it comes to database relationships hence what I suspect is a basic question! I have two database tables as follows:</p>
  <p><strong>Projects</strong></p>
  <ul>
  <li>id</li>
  <li>company_id</li>
  <li>name</li>
  <li>etc...</li>
  </ul>
  <p><strong>rfis</strong></p>
  <ul>
  <li>id</li>
  <li>project_id (foreign key is id on the Projects table above)</li>
  <li>Number (this is the column I need help with - more below)</li>
  <li>question</li>
  </ul>
  <p>The relationships at the Model level for these tables are as follows:</p>
  <p><strong>Project</strong></p>
  <pre><code>public function rfi()
  {
      return $this-&gt;hasMany('App\Rfi'); 
  }
  </code></pre>
  <p><strong>RFI</strong></p>
  <pre><code>public function project()
  {
      return $this-&gt;belongsTo('App\Project');
  }
  </code></pre>
  <p><strong>What I'm trying to achieve</strong>
  In the RFI table I need a system generated number or essentially a count of RFI's. Where I'm finding the difficulty is that I need the RFI number/count to start again for each project. To clarify, please see the RFI table below which I have manually created with the the 'number' how I would like it displayed (notice it resets for each new project and the count starts from there).</p>
  <p><a href="https://i.stack.imgur.com/GvicW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GvicW.png" alt="enter image description here" /></a></p>
  <p>Any assistance would be much appreciated!
  Todd</p>