title: Laravel store value from for-each loop and passed it as array
body: <p>I have two for-each loop inside my create view [Subject_id, Lead_id], I want to store the for-each value into my database using array approach, and I couldn't make it work can anyone amend my codes or point me to a proper way thanks.</p>
  
  <p><strong>Controller:</strong></p>
  
  <pre><code>public function store(Request $request)
  {
      //
      $input = $request-&gt;all();
      $items = array(['Subject_id','Lead_id']);
      foreach($input as $inputs) {
          $items[] = $inputs;
      }
      $scores = new Score();
      $scores-&gt;Subject_id=$items['Subject_id'];
      $scores-&gt;Lead_id=$items['Lead_id'];
      $scores-&gt;save();
      dd($request-&gt;all());
      return redirect()-&gt;route('scores.create')-&gt;with('notif', 'Success.');
  }
  </code></pre>
  
  <p><strong>this is the message:</strong><a href="https://i.stack.imgur.com/WpehO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WpehO.jpg" alt="enter image description here"></a></p>
  
  <p><strong>create view</strong></p>
  
  <pre><code>@foreach ($leads as $lead)
      &lt;tr&gt;
          &lt;td&gt;{{ $lead-&gt;student_name }}&lt;/td&gt;
          &lt;td&gt;&lt;input type="checkbox" class="checkbox" name="Lead_id[]"  value="{{ $lead-&gt;id }}"&gt;&lt;/td&gt;
      &lt;/tr&gt;
  @endforeach
  @foreach($subjects as $subject)
   &lt;label &gt;
      &lt;input type="checkbox" name="Subject_id[]" value="{{ $subject-&gt;id }}"&gt;
      {{ $subject-&gt;subject_name }}
   &lt;/label&gt;
   @endforeach
  </code></pre>
  
  <p>DD Result:<a href="https://i.stack.imgur.com/3tfxD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3tfxD.jpg" alt="enter image description here"></a></p>