How to Get Table Name from Model in 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 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 example.
Example:
Read Also: Laravel Model Events Tutorial
$item = new Item;
$table = $item->getTable();
print_r($table);

Hardik Savani
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
My name is Hardik Savani. I'm a full-stack developer, entrepreneur and owner of Aatman Infotech. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.
***Do you want me hire for your Project Work? Then Contact US.
We are Recommending you:
- Laravel Eloquent Delete Record By ID Example
- Delete All Records from Table in Laravel Eloquent
- Laravel Eloquent inRandomOrder() Method Example
- Laravel Eloquent whereNull() Query Example
- Laravel Eloquent whereBetween() Query Example
- Laravel Model Caching - Performance Boost Tutorial
- How to use Union query with Laravel Eloquent?
- Laravel One to Many Eloquent Relationship Tutorial
- How to disable model timestamps in Laravel?
- Laravel - Google reCaptcha Code using anhskohbo/no-captcha
- How to get last inserted id in Laravel?