Вопрос

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!

Это было полезно?

Решение

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.

Другие советы

In pivot tables the timestamps are essential. The datatype for timestap is datetime.

I have just had the same problem. Fixed it by adding:

Laravel\Database\Eloquent\Pivot::$timestamps = false;

to application/start.php

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top