Skip to content

Instantly share code, notes, and snippets.

@sachinkiranti
Last active August 15, 2018 03:32
Show Gist options
  • Save sachinkiranti/96d73886a46abece41735722a109807a to your computer and use it in GitHub Desktop.
Save sachinkiranti/96d73886a46abece41735722a109807a to your computer and use it in GitHub Desktop.
Laravel Useful helpers
<?php
if (! function_exists('change_db_storage')) :
/**
* Changing all tables database storage
* i.e InnoDB/MyISAM
*/
function change_db_storage( $storage = 'InnoDB' ) {
$tables = DB::select('SHOW TABLES');
$tables = array_map(function ($table) use ($storage) {
DB::statement(sprintf("ALTER TABLE %s ENGINE = {$storage}", $table->Tables_in_smscore_db));
return $table->Tables_in_smscore_db . " changed to {$storage} successfully.";
}, $tables);
return $tables;
}
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment