title: Passing an id to other controller
body: <pre><code>$job-&gt;created_by = $input['created_by'];
  </code></pre>
  
  <p>I want to pass user id in this array which is in other table what should I do? </p>
  
  <p>The field is a foreign key.</p>
  
  <p>When I run this it throws an exception</p>
  
  <pre><code>SQLSTATE[23000]: Integrity constraint violation: 1452
       Cannot add or update a child row: a foreign key constraint fails 
       (`freight`.`jobs`, CONSTRAINT `approved_by` FOREIGN KEY (`created_by`)
       REFERENCES `users` (`id`))
  
       (SQL: insert into `jobs`
             (`company_id`, `origin`, `commodity`, `destination`,
              `created_by`, `approved_by`, `date`, `carrier`, `consolidator`,
              `overseas_agt`, `prepaid_fob`, `free_time`, `wt_pcs`, 
              `updated_at`, `created_at`)
             values (2, , , , asdsadasdsad, asdsadasdsad, , , , , , , ,
                     2015-11-26 07:32:02, 2015-11-26 07:32:02)
       )
  </code></pre>