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.
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.
You can also read: How to clear cache using URL in Laravel
Hi nice tutorial love your blog so much