Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel php tinker command to show tables and structures?

What is he command within Laravels' php artisan tinker that shows tables and/or structure of those tables?

like image 493
The Man Avatar asked May 28 '16 22:05

The Man


3 Answers

To get all tables, use this:
$tables = \DB::select('show tables');.

To get all columns of table, use this:
$columns = \Schema::getColumnListing('<table_name>');

like image 88
Giedrius Kiršys Avatar answered Oct 19 '22 02:10

Giedrius Kiršys


For sqlite, use:

DB::select('SELECT NAME FROM sqlite_master WHERE type="table"');
like image 27
STWilson Avatar answered Oct 19 '22 01:10

STWilson


For me it was

$flights = Flight::all();

that finally gave me the data from my table https://laravel.com/docs/8.x/eloquent#retrieving-models

like image 22
Jacob Corum Avatar answered Oct 19 '22 00:10

Jacob Corum