如何在 Laravel 中返​​回数据库表名 [英] How to return database table name in Laravel

查看:17
本文介绍了如何在 Laravel 中返​​回数据库表名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让我使用的模型正在使用当前的数据库表?我看到 Laravel/Database/Eloquent/model.php 中有一个 table() 函数,但我一直没有成功调用它从我所在的模型中调用它.

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 I've been unsuccessful calling it calling it from the model that I'm in.

推荐答案

EloquentModel 所以你应该能够使用 $model->getTable().

There is a public getTable() method defined in EloquentModel so you should be able to use $model->getTable().

这篇关于如何在 Laravel 中返​​回数据库表名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆