How to return database table name in Laravel

前端 未结 11 565
执念已碎
执念已碎 2020-12-28 13:28

Is there a way that I can get the current database table in use by the model that I\'m in? I see that there is a table() function in Laravel/Database/Eloquent/model.php but

11条回答
  •  别那么骄傲
    2020-12-28 13:31

    In Laravel 4 use static method

    $table_name = Model::getTable();
    

    or "self" inside Eloquent Model

    $table_name = self::getTable();
    

提交回复
热议问题