【发布时间】:2014-12-19 04:46:24
【问题描述】:
如何从 laravel 中的模型中获取主键名称?
喜欢这个
dd(User::primaryKeyName()); // -> 'user_id'
如果“订单”为空,我想对主要数据进行排序
$data = User::orderBy(Input::get('order', User::primaryKey()), 'ASC')->get();
但是有
Non-static method Illuminate\Database\Eloquent\Model::getKeyName() should not be called statically, assuming $this from incompatible context
【问题讨论】: