jeudi 26 novembre 2015

Passing an id to other controller

$job->created_by = $input['created_by'];

I want to pass user id in this array which is in other table what should I do?

The field is a foreign key.

When I run this it throws an exception

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)
     )



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Hp1jSm
via IFTTT

Aucun commentaire:

Enregistrer un commentaire