Here, we fetch all tables names with prefix from database using laravel DB facade. So if you require to get all tables then you are at right place.
As we can get simply all table lists by following sql query:
SHOW TABLES
In Laravel 5 application we will use same above query by using laravel DB select method. So let's see bellow example:
Example:
$tables = \DB::select('SHOW TABLES');
$tables = array_map('current',$tables);
dd($tables);
Output:
Array
(
[0] => ban
[1] => events
[2] => log_activities
[3] => migrations
[4] => password_resets
[5] => products
[6] => tags
[7] => users
[8] => youtube_access_tokens
)
I hope you found your solution....
Do you like below Tutorials ?
- PHP Laravel 5.5 - import export data into excel and csv using maatwebsite
- Laravel 7.x and 6.x create custom facade example from scratch
- Node JS - Get Real time online users counter using socket io example
- PHP Laravel 7.x and 6.x - Bootstrap Admin Theme Integration example from scratch
- MySQL Query - How to select records of today to next Sunday ?
- Laravel 7.x and 6.x - username custom validation example
- Laravel 5.5 - Import Extract zip file using chumper/zipper package
- PHP Laravel Set Custom Validation Error Messages Example