【发布时间】:2015-10-07 12:23:54
【问题描述】:
假设我有这个 Eloquent 模型类:
class Fruit extends Model
{
//whatever not following the conventions
protected $table = 'the_fruit_table';
}
在我的代码中,我有一个带有表名的变量
$table_name = 'the_fruit_table';
有没有办法获得负责该表的模型的名称? 所以在这种情况下,我会得到字符串:
'\App\Fruit'
【问题讨论】:
标签: php laravel model eloquent