Take the 2-minute tour ×  I have several tables in my database.
Blogs, Users, Posts, Tags are the main ones. Also I have linking
tables: User_blogs, Blog_posts & Post_tags.  My question is how
to use Laravel's classes and methods like belogs_to(),
has_many(). I need someone shed light on it. I've read many
articles and documentation, but I'm still confused.
share|improve this question add comment  1 Answer  Generally
laravel is smart enough to detect many-to-many relationships if
you set up your tables properly Both table names should be not
pluralized in the intermediate/pivot table so you should have
Users, Blogs, Posts, Tags as your individual tables and
User_Blog, Blog_Post, Post_Tag as your intermediate tables. In
those tables the cols should properly reflect the tablename_id
(in lowercase) so in User_Blog it should have 3 cols id,
user_id, blog_id etc and so on for the other columns.  In your
models you just need to set up the many-to-many relationships
class User extends Eloquent      public function