Setting up Eloquent relationships in Laravel for existing InnoDB relationships

Posted by adam on Stack Overflow See other posts from Stack Overflow or by adam
Published on 2012-10-06T21:33:53Z Indexed on 2012/10/06 21:37 UTC
Read the original article Hit count: 454

I have an initial migration that sets up two tables (users and projects), with a relationship (innoDB).

$table->foreign('user_id')->references('id')->on('users');

I have two Eloquent models set up, blank except for the relationship:

return $this->has_many('Project');

Do i definitely need to tell eloquent about the relationship in the models and the database? I'd assumed something as comprehensive as Laravel would infer it from the Schema? Is there something I'm missing?

© Stack Overflow or respective owner

Related posts about migration

Related posts about schema