【发布时间】:2018-09-16 23:50:49
【问题描述】:
我正在尝试覆盖 created_at 和 updated_at 的 laravel eloquent 模型常量:
namespace App;
use Illuminate\Database\Eloquent\Model;
class Visit extends Model
{
const CREATED_AT = 'creation_date';
const UPDATED_AT = 'last_update';
}
然后获取最新的条目:
dd(Visit::latest()->get());
但出现未知列错误:
"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'created_at' in
'order clause' (SQL: select * from `visits` order by `created_at` desc)"
还有什么需要做的才能让它工作吗?
【问题讨论】:
标签: php laravel eloquent laravel-eloquent