laravel get all table names

Today, We want to share with you laravel get all table names.In this post we will show you fetch the tables list from database in laravel, hear for How to get table name and table column names from model in Laravel we will give you demo and example for implement.In this post, we will learn about laravel get table name with prefix with an example.

laravel get all table names

There are the Following The simple About fetch the tables list of database in laravel 7 Full Information With Example and source code.

As I will cover this Post with live Working example to develop how to get table column names in laravel, so the laravel eloquent dynamic table name is used for this example is following below.

How to get all tables lists of database in Laravel

Example: laravel get lists on tables

$tables = \DB::select('SHOW TABLES');
$tables = array_map('current',$tables);


fetch the tables list from database in laravel

     [0] => doctor_mst
     [1] => patient
     [2] => nurses
     [3] => registrars
     [4] => residents
     [5] => interns
     [6] => student_doctors
     [7] => consultants
     [8] => senior_consultants

How to Get Table Name from Model in Laravel?

Laravel Controller

laravel get table name from model, laravel eloquent table name, get table name from model laravel 5, laravel model table name

$all_item = new Item;
$table = $all_item->getTable();

How to fetch the tables list in database in Laravel

list out the tables in database

$data_tables = DB::select('SHOW TABLES');
foreach($data_tables as $table)
      echo $table->Tables_in_db_name;


foreach ($data_tables as $table) {
    foreach ($table as $key => $value)
        echo $value;

$tables = DB::connection()->getDoctrineSchemaManager()->listTableNames();
Web Programming Tutorials Example with Demo

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about get column name from table in laravel.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment