How to get the table name of a model?

0

I need to get the name of the table that is used by given model in my application written in Laravel .

Previously, in Laravel 3 , it was only necessary to do this to find out the name of the table:

   var_dump(MeuModel::$table);

However, in Laravel 4 >= this property is no longer static, much less public .

For example:

 class Usuario extends Eloquent
 {
    protected $table = 'tbl_usuarios';
 }

That is, with the property being protected it is not possible to get it "outside of the model instance".

I need the Controller to get the value of protected $table to display it.

Is there any way to do this in Laravel ?

    
asked by anonymous 19.04.2016 / 15:16

1 answer

0

To get the name of a model table, use the getTable method, which inherits from Eloquent .

$tabela_usuarios = (new Usuario)->getTable();
    
19.04.2016 / 18:13