title: laravel many to many relationship not store in pivot table
body: <p>I have two tables developer table and skill table which are linked with many to many relationship developer_skill table. I want to store developer_id and skill_id is in pivot table.</p>
  <p>but when developer add their skills and submit it return error.</p>
  <p>on developer table data add but in pivot table data not added.
  <strong>error</strong></p>
  <pre><code>SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'developer_id' cannot be null (SQL: insert into `developer_skill` (`developer_id`, `skill_id`) values (, 5))
  </code></pre>
  <p><strong>developer controller to store data</strong></p>
  <pre><code>namespace App\Http\Controllers;
  use Illuminate\Http\Request;
  use App\Developer; 
  use App\Skill as skill;
  
  class developerController extends Controller
  {
      public function __construct(Developer $Developer, skill $skill)
      {
          $this-&gt;Developer = $Developer;
          $this-&gt;skill = $skill;
      }
  
       public function store(Request $request)
        {
         $skills = implode(',', $request-&gt;user_skills);
      
            $data = array(
                  'name' =&gt; $request-&gt;name,
                  'skills' =&gt; $skills,
              );
      
              if ($this-&gt;Developer-&gt;create($data)) {
                  $syncTagData = array();
                  if (!empty($request-&gt;user_skills)) {
                      $syncTagData = $request-&gt;user_skills;
                  }
      
                  $this-&gt;Developer-&gt;user_skills()-&gt;sync($syncTagData);
              }
  }
  }
  </code></pre>
  <p><strong>developer_skill</strong></p>
  <pre><code>developer_id
  skill_id
  </code></pre>
  <p><strong>skill model</strong></p>
  <pre><code>public function users()
  {
      return $this-&gt;belongsToMany(Developer::class);
  }
  </code></pre>
  <p><strong>developer model</strong></p>
  <pre><code>public function user_skills()
      {
          return $this-&gt;belongsToMany('App\Skill');
  
  }
  </code></pre>