Search code examples
many-to-manylaravellaravel-3

Laravel Many-to-Many Relationship


I have two models User and Role i have turned off timestamps for both of them like so

public static $timestamps=false

and also i have removed the created_at and updated_at columns from both the tables(users & roles).

I also have a 3rd pivot table called role_user with 3 columns id,user_id and role_id

when i try find the role of a user i keep getting Column unknown role_user.created_at not found.`

Please Help am stuck with this problem. thank you in advance!


Solution

  • In laravel 3 pivot tables needs to have a time stamp. Either add this line to you migrations: $table->timestamps() or create the columns manually. I believe the column type is datetime for both the created_at and updated_at columns.