Laravel

How to get all data from database in Laravel

In this article we will learn about how to get all data from database in laravel , I will show you how to get all table in the from the database, then I will show you how to get all table column in laravel.

Get all table name from the database in laravel

In the below code I will show how we can get all tabel name from the database in laravel

$tables_list = DB::select('SHOW TABLES');
dd($tables_list);

when you run the above code, you will have output like the below one.

all table list from database in laravel

Get all the column name of the given table

To the all the column name of the given table,use the below code.

$tableColumns = DB::connection()->getSchemaBuilder()->getColumnListing('Your_table_name');
dd($tableColumns);

when you run the above code you have the output like the below image.

all the table column name from database in laravel

Shaiv Roy

Hy Myself shaiv roy, I am a passionate blogger and love to share ideas among people, I am having good experience with laravel, vue js, react, flutter and doing website and app development work from last 7 years.

Related Articles

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button