get all table names in laravel code example
Example 1: get table name from model laravel
$item = new Item;
$table = $item->getTable();
print_r($table);
Example 2: get table column names sql laravel
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;
public function getTableColumns($table)
{
return DB::getSchemaBuilder()->getColumnListing($table);
// OR
return Schema::getColumnListing($table);
}
Example 3: laravel list of tables
DB::select('SHOW TABLES')