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.

Read Also:  Laravel Group by not working - LIMIT or GROUP BY with prepared statement not working

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

Read Also:  Laravel Combine two DB query results Example

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 :

Read Also:  angular Recursive Templates Dynamic nested Tree


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.

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  ASP.NET AJAX partial postback in UpdatePanel control
  2. Read Also:  laravel 6 auth
  3. Read Also:  Laravel whereRaw havingRaw and orderByRaw Example
  4. Read Also:  Multiple file Upload in Laravel 5.7 with validation
  5. Read Also:  laravel 6 Delete Multiple Records Eloquent
  6. Read Also:  JavaScript Top 5 Most useful JSON Example
  7. Read Also:  Laravel 6 drop column if exists MySQL using Migration
  8. Read Also:  cURL POST header parameters file json request
  9. Read Also:  Laravel Many to many relationships with itself
  10. Read Also:  Laravel Eloquent Update increment decrement Database column value