Today now in this post i will show you How to Get Table Name from Model in Laravel? If we need to get the table name from our model in our laravel application. So then this post will help you how to get the table name in laravel 6, laravel 7 and laravel 8 application. We know Laravel based is MVC. So, we need to create the model for every table on that way we can write the database logic on our model. But if we need to get the table name from our model then we can get this by using getTable() of model.
Laravel eloquent model is provide us several methods as like for all(), get(), first() etc. So that will helps to get the table record from our model table.
We can get the table name it is simply to call by using getTable() of model object. So how to call this in method as like as bellow example.
$item = new Item; $table = $item->getTable(); print_r($table);
Thanks for read. I hope it help you. For more you can follow us on facebook