How to Get Table Name from Model in Laravel?

By Hardik Savani April 16, 2024 Category : Laravel

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, laravel 8, laravel 9, laravel 10 and laravel 11 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 example.

Example:

$item = new Item;

$table = $item->getTable();

print_r($table);

Shares