How to Get Table Name from Model in Laravel?

About Us:

We are from free coder. We are a group of web developers who are passionate about web development. You can learn from us php, laravel, node js, vue js, react js and many other topic on web developement.
we are very happy to help you.
free coder

Today what you are going to learn:

If you need to get table name from model in your laravel application then this post can help you to get table name in laravel 6, laravel 7 and laravel 8 app. Laravel based on MVC. So, we require to create model for every table that way we can write database logic on model. But if you require to get table name from model then you can get using getTable() of model.

Laravel eloquent model provide several methos like for all(), get(), first() etc, that helps to get table record from model table.

You can get table name simply call getTable() of model object, so how to call this method as bellow lesson.

Example:

$item = new Item;

$table = $item->getTable();

print_r($table);

Recent Posts

Related Posts