How to get Database Table Name From Laravel Eloquent Model?
Hello Everyone, In this article, I will show some tips to get your database table using eloquent.
For instance, if you need to get a database table name from any model in your laravel application. Based on MVC Architecture. There are few ways of doing such, but many use this approach which is common in the laravel community. getTable().
Laravel eloquent model provides several methods like for all(), get(), first(), etc, that helps to get table record from the model table.
You can get a table name by simply calling getTable() of the model object, So let's see how to call this method as below example.
$user = new User; $tableName = $user->getTable(); dd($tableName);
Thank you for reading this article, if you have anything that you wanted to ask leave your comment and we discuss it. I hope you understand a How to get Database Table Name From Laravel Eloquent Model? by now.
Leave a comment
How to get Database Table Name From Laravel Eloquent Model?Jun 4, 2022
How to refresh a page if no activity after 1 minute using jQueryJun 4, 2022
Laravel Eloquent whereBetween() Method | How to use whereBetween() Query in LaravelJun 4, 2022
Laravel Eloquent whereRaw Method | How to use Laravel Eloquent whereRaw() MethodJun 4, 2022
Laravel Library Management System Project with Source CodeMay 14, 2022