| @@ -3,21 +3,21 @@ | ||
| 3 | 3 | return array( | 
| 4 | 4 | 'backup' => array( | 
| 5 | 5 | |
| 6 | - /** | |
| 7 | - * The disk where your files will be backed up | |
| 8 | - **/ | |
| 6 | + /** | |
| 7 | + * The disk where your files will be backed up | |
| 8 | + **/ | |
| 9 | 9 | 'disk' => 'local', | 
| 10 | 10 | |
| 11 | 11 | |
| 12 | 12 | /** | 
| 13 | - * Location on disk where to backup migratons | |
| 14 | - **/ | |
| 13 | + * Location on disk where to backup migratons | |
| 14 | + **/ | |
| 15 | 15 | 'migrations' => 'backup/migrations/', | 
| 16 | 16 | |
| 17 | 17 | |
| 18 | 18 | /** | 
| 19 | - * Location on disk where to backup seeds | |
| 20 | - **/ | |
| 19 | + * Location on disk where to backup seeds | |
| 20 | + **/ | |
| 21 | 21 | 'seeds' => 'backup/seeds/' | 
| 22 | 22 | |
| 23 | 23 | ), | 
| @@ -33,9 +33,9 @@ | ||
| 33 | 33 |      { | 
| 34 | 34 | $this->app->singleton( | 
| 35 | 35 | DbMigrations::class, | 
| 36 | -            function () { | |
| 36 | +            function() { | |
| 37 | 37 |                  $connType = Config::get('database.default'); | 
| 38 | -                $database = Config::get('database.connections.'.$connType); | |
| 38 | +                $database = Config::get('database.connections.' . $connType); | |
| 39 | 39 | |
| 40 | 40 | return new DbMigrations($database['database']); | 
| 41 | 41 | } | 
| @@ -54,9 +54,9 @@ discard block | ||
| 54 | 54 | |
| 55 | 55 | $seed = $this->compile(); | 
| 56 | 56 |          $absolutePath = Config::get('db-exporter.export_path.seeds'); | 
| 57 | - $this->filename = ucfirst(Str::camel($this->database)).'DatabaseSeeder'; | |
| 57 | + $this->filename = ucfirst(Str::camel($this->database)) . 'DatabaseSeeder'; | |
| 58 | 58 | $this->makePath($absolutePath); | 
| 59 | -        file_put_contents($absolutePath."/{$this->filename}.php", $seed); | |
| 59 | +        file_put_contents($absolutePath . "/{$this->filename}.php", $seed); | |
| 60 | 60 | } | 
| 61 | 61 | |
| 62 | 62 | //end write() | 
| @@ -106,7 +106,7 @@ discard block | ||
| 106 | 106 | |
| 107 | 107 |              if ($this->hasTableData($tableData)) { | 
| 108 | 108 | $stub .= " | 
| 109 | -        DB::table('".$tableName."')->insert([ | |
| 109 | +        DB::table('".$tableName . "')->insert([ | |
| 110 | 110 |              {$insertStub} | 
| 111 | 111 | ]);"; | 
| 112 | 112 | } | 
| @@ -127,10 +127,10 @@ discard block | ||
| 127 | 127 | protected function compile() | 
| 128 | 128 |      { | 
| 129 | 129 | // Grab the template | 
| 130 | - $template = File::get(__DIR__.'/stubs/seed.stub'); | |
| 130 | + $template = File::get(__DIR__ . '/stubs/seed.stub'); | |
| 131 | 131 | |
| 132 | 132 | // Replace the classname | 
| 133 | -        $template = str_replace('{{className}}', ucfirst(Str::camel($this->database)).'DatabaseSeeder', $template); | |
| 133 | +        $template = str_replace('{{className}}', ucfirst(Str::camel($this->database)) . 'DatabaseSeeder', $template); | |
| 134 | 134 |          $template = str_replace('{{run}}', $this->seedingStub, $template); | 
| 135 | 135 | |
| 136 | 136 | return $template; | 
| @@ -27,27 +27,27 @@ | ||
| 27 | 27 | * @var array | 
| 28 | 28 | **/ | 
| 29 | 29 | protected $selects = array( | 
| 30 | - 'column_name as Field', | |
| 31 | - 'column_type as Type', | |
| 32 | - 'is_nullable as Null', | |
| 33 | - 'column_key as Key', | |
| 34 | - 'column_default as Default', | |
| 35 | - 'extra as Extra', | |
| 36 | - 'data_type as Data_Type', | |
| 37 | - ); | |
| 30 | + 'column_name as Field', | |
| 31 | + 'column_type as Type', | |
| 32 | + 'is_nullable as Null', | |
| 33 | + 'column_key as Key', | |
| 34 | + 'column_default as Default', | |
| 35 | + 'extra as Extra', | |
| 36 | + 'data_type as Data_Type', | |
| 37 | + ); | |
| 38 | 38 | /** | 
| 39 | 39 | * Select fields from constraints. | 
| 40 | 40 | * | 
| 41 | 41 | * @var array | 
| 42 | 42 | **/ | 
| 43 | 43 | protected $constraints = array( | 
| 44 | - 'key_column_usage.table_name as Table', | |
| 45 | - 'key_column_usage.column_name as Field', | |
| 46 | - 'key_column_usage.referenced_table_name as ON', | |
| 47 | - 'key_column_usage.referenced_column_name as References', | |
| 48 | - 'REFERENTIAL_CONSTRAINTS.UPDATE_RULE as onUpdate', | |
| 49 | - 'REFERENTIAL_CONSTRAINTS.DELETE_RULE as onDelete', | |
| 50 | - ); | |
| 44 | + 'key_column_usage.table_name as Table', | |
| 45 | + 'key_column_usage.column_name as Field', | |
| 46 | + 'key_column_usage.referenced_table_name as ON', | |
| 47 | + 'key_column_usage.referenced_column_name as References', | |
| 48 | + 'REFERENTIAL_CONSTRAINTS.UPDATE_RULE as onUpdate', | |
| 49 | + 'REFERENTIAL_CONSTRAINTS.DELETE_RULE as onDelete', | |
| 50 | + ); | |
| 51 | 51 | |
| 52 | 52 | protected function getTables() | 
| 53 | 53 |      { | 
| @@ -53,7 +53,7 @@ discard block | ||
| 53 | 53 |      { | 
| 54 | 54 | $pdo = DB::connection()->getPdo(); | 
| 55 | 55 | |
| 56 | -        return $pdo->query('SELECT table_name FROM information_schema.tables WHERE table_schema="'.$this->database.'"'); | |
| 56 | +        return $pdo->query('SELECT table_name FROM information_schema.tables WHERE table_schema="' . $this->database . '"'); | |
| 57 | 57 | } | 
| 58 | 58 | |
| 59 | 59 | //end getTables() | 
| @@ -62,7 +62,7 @@ discard block | ||
| 62 | 62 |      { | 
| 63 | 63 | $pdo = DB::connection()->getPdo(); | 
| 64 | 64 | |
| 65 | -        return $pdo->query('SHOW INDEX FROM '.$this->database.'.'.$table.' WHERE Key_name != "PRIMARY"'); | |
| 65 | +        return $pdo->query('SHOW INDEX FROM ' . $this->database . '.' . $table . ' WHERE Key_name != "PRIMARY"'); | |
| 66 | 66 | } | 
| 67 | 67 | |
| 68 | 68 | //end getTableIndexes() | 
| @@ -112,7 +112,7 @@ discard block | ||
| 112 | 112 | */ | 
| 113 | 113 | protected function getTableData($table) | 
| 114 | 114 |      { | 
| 115 | - return DB::table($this->database.'.'.$table)->get(); | |
| 115 | + return DB::table($this->database . '.' . $table)->get(); | |
| 116 | 116 | } | 
| 117 | 117 | |
| 118 | 118 | //end getTableData() | 
| @@ -129,7 +129,7 @@ discard block | ||
| 129 | 129 | $directories = explode($del, $path); | 
| 130 | 130 |          foreach ($directories as $directory) { | 
| 131 | 131 |              if (!empty($directory)) { | 
| 132 | - $dir .= $del.$directory; | |
| 132 | + $dir .= $del . $directory; | |
| 133 | 133 | } | 
| 134 | 134 | |
| 135 | 135 |              if (!is_dir($dir)) { | 
| @@ -33,7 +33,7 @@ discard block | ||
| 33 | 33 |      { | 
| 34 | 34 | $this->publishes( | 
| 35 | 35 | [ | 
| 36 | -             realpath(__DIR__.'/../').'/config/db-exporter.php' => config_path('db-exporter.php'), | |
| 36 | +                realpath(__DIR__.'/../').'/config/db-exporter.php' => config_path('db-exporter.php'), | |
| 37 | 37 | ], | 
| 38 | 38 | 'config' | 
| 39 | 39 | ); | 
| @@ -44,7 +44,7 @@ discard block | ||
| 44 | 44 | ); | 
| 45 | 45 | // Instatiate a new DbMigrations class to send to the handler | 
| 46 | 46 | $this->migrator = $migrator; | 
| 47 | - // Load the alias | |
| 47 | + // Load the alias | |
| 48 | 48 | $this->loadAlias(); | 
| 49 | 49 | } | 
| 50 | 50 | |
| @@ -55,7 +55,7 @@ discard block | ||
| 55 | 55 | $this->app->register(DbMigrationsServiceProvider::class); | 
| 56 | 56 | // Register the base export handler class | 
| 57 | 57 | $this->registerDbExportHandler(); | 
| 58 | - // Handle the artisan commands | |
| 58 | + // Handle the artisan commands | |
| 59 | 59 | $this->registerCommands(); | 
| 60 | 60 | } | 
| 61 | 61 | |
| @@ -74,9 +74,9 @@ discard block | ||
| 74 | 74 | public function registerCommands() | 
| 75 | 75 |      { | 
| 76 | 76 | $commands = [ | 
| 77 | - 'Migrations', | |
| 78 | - 'Seeds', | |
| 79 | - 'Backup', | |
| 77 | + 'Migrations', | |
| 78 | + 'Seeds', | |
| 79 | + 'Backup', | |
| 80 | 80 | ]; | 
| 81 | 81 | |
| 82 | 82 |          foreach ($commands as $command) { | 
| @@ -33,13 +33,13 @@ discard block | ||
| 33 | 33 |      { | 
| 34 | 34 | $this->publishes( | 
| 35 | 35 | [ | 
| 36 | -             realpath(__DIR__.'/../').'/config/db-exporter.php' => config_path('db-exporter.php'), | |
| 36 | +             realpath(__DIR__ . '/../') . '/config/db-exporter.php' => config_path('db-exporter.php'), | |
| 37 | 37 | ], | 
| 38 | 38 | 'config' | 
| 39 | 39 | ); | 
| 40 | 40 | |
| 41 | 41 | $this->mergeConfigFrom( | 
| 42 | - realpath(__DIR__.'/../').'/config/db-exporter.php', | |
| 42 | + realpath(__DIR__ . '/../') . '/config/db-exporter.php', | |
| 43 | 43 | 'db-exporter' | 
| 44 | 44 | ); | 
| 45 | 45 | // Instatiate a new DbMigrations class to send to the handler | 
| @@ -98,7 +98,7 @@ discard block | ||
| 98 | 98 |      { | 
| 99 | 99 | $this->app->singleton( | 
| 100 | 100 | 'db-exporter.migrations', | 
| 101 | -            function ($app) { | |
| 101 | +            function($app) { | |
| 102 | 102 | return new Commands\MigrationsGeneratorCommand($app[DbExportHandler::class]); | 
| 103 | 103 | } | 
| 104 | 104 | ); | 
| @@ -113,7 +113,7 @@ discard block | ||
| 113 | 113 |      { | 
| 114 | 114 | $this->app->singleton( | 
| 115 | 115 | 'db-exporter.seeds', | 
| 116 | -            function ($app) { | |
| 116 | +            function($app) { | |
| 117 | 117 | return new Commands\SeedGeneratorCommand($app[DbExportHandler::class]); | 
| 118 | 118 | } | 
| 119 | 119 | ); | 
| @@ -125,7 +125,7 @@ discard block | ||
| 125 | 125 |      { | 
| 126 | 126 | $this->app->singleton( | 
| 127 | 127 | 'db-exporter.backup', | 
| 128 | -            function () { | |
| 128 | +            function() { | |
| 129 | 129 | return new Commands\CopyToRemoteCommand(new Server()); | 
| 130 | 130 | } | 
| 131 | 131 | ); | 
| @@ -140,7 +140,7 @@ discard block | ||
| 140 | 140 |      { | 
| 141 | 141 | $this->app->bind( | 
| 142 | 142 | DbExportHandler::class, | 
| 143 | -            function ($app) { | |
| 143 | +            function($app) { | |
| 144 | 144 | // Instatiate a new DbSeeding class to send to the handler | 
| 145 | 145 | $seeder = new DbSeeding($app[DbMigrations::class]->database); | 
| 146 | 146 | |
| @@ -151,7 +151,7 @@ discard block | ||
| 151 | 151 | |
| 152 | 152 | $this->app->bind( | 
| 153 | 153 | 'DbExporter', | 
| 154 | -            function ($app) { | |
| 154 | +            function($app) { | |
| 155 | 155 | return $app[DbExportHandler::class]; | 
| 156 | 156 | } | 
| 157 | 157 | ); | 
| @@ -87,7 +87,7 @@ | ||
| 87 | 87 | */ | 
| 88 | 88 | public function ignore(...$tables) | 
| 89 | 89 |      { | 
| 90 | - DbExporter::$ignore = array_merge(DbExporter::$ignore, (array) $tables); | |
| 90 | + DbExporter::$ignore = array_merge(DbExporter::$ignore, (array)$tables); | |
| 91 | 91 | |
| 92 | 92 | return $this; | 
| 93 | 93 | } | 
| @@ -37,9 +37,9 @@ discard block | ||
| 37 | 37 | // Symfony style block messages | 
| 38 | 38 |          $formatter = $this->getHelperSet()->get('formatter'); | 
| 39 | 39 | $errorMessages = array( | 
| 40 | - $title, | |
| 41 | - $message, | |
| 42 | - ); | |
| 40 | + $title, | |
| 41 | + $message, | |
| 42 | + ); | |
| 43 | 43 | $formattedBlock = $formatter->formatBlock($errorMessages, $style, true); | 
| 44 | 44 | $this->line($formattedBlock); | 
| 45 | 45 | } | 
| @@ -62,11 +62,11 @@ discard block | ||
| 62 | 62 |      { | 
| 63 | 63 | return array( | 
| 64 | 64 | array( | 
| 65 | - 'database', | |
| 66 | - InputArgument::OPTIONAL, | |
| 67 | - 'Override the application database', | |
| 65 | + 'database', | |
| 66 | + InputArgument::OPTIONAL, | |
| 67 | + 'Override the application database', | |
| 68 | 68 | ), | 
| 69 | - ); | |
| 69 | + ); | |
| 70 | 70 | } | 
| 71 | 71 | |
| 72 | 72 | //end getArguments() | 
| @@ -75,13 +75,13 @@ discard block | ||
| 75 | 75 |      { | 
| 76 | 76 | return array( | 
| 77 | 77 | array( | 
| 78 | - 'ignore', | |
| 79 | - 'i', | |
| 80 | - InputOption::VALUE_REQUIRED, | |
| 81 | - 'Ignore tables to export, seperated by a comma', | |
| 82 | - null, | |
| 78 | + 'ignore', | |
| 79 | + 'i', | |
| 80 | + InputOption::VALUE_REQUIRED, | |
| 81 | + 'Ignore tables to export, seperated by a comma', | |
| 82 | + null, | |
| 83 | 83 | ), | 
| 84 | - ); | |
| 84 | + ); | |
| 85 | 85 | } | 
| 86 | 86 | |
| 87 | 87 | //end getOptions() | 
| @@ -25,7 +25,7 @@ | ||
| 25 | 25 | protected function getDatabaseName() | 
| 26 | 26 |      { | 
| 27 | 27 |          $connType = Config::get('database.default'); | 
| 28 | -        $database = Config::get('database.connections.'.$connType); | |
| 28 | +        $database = Config::get('database.connections.' . $connType); | |
| 29 | 29 | |
| 30 | 30 | return $database['database']; | 
| 31 | 31 | } | 
| @@ -57,9 +57,9 @@ | ||
| 57 | 57 | |
| 58 | 58 | private function getFilename() | 
| 59 | 59 |      { | 
| 60 | - $filename = ucfirst(Str::camel($this->database)).'DatabaseSeeder'; | |
| 60 | + $filename = ucfirst(Str::camel($this->database)) . 'DatabaseSeeder'; | |
| 61 | 61 | |
| 62 | -        return Config::get('db-exporter.export_path.seeds')."/{$filename}.php"; | |
| 62 | +        return Config::get('db-exporter.export_path.seeds') . "/{$filename}.php"; | |
| 63 | 63 | } | 
| 64 | 64 | |
| 65 | 65 | //end getFilename() | 
| @@ -42,9 +42,9 @@ | ||
| 42 | 42 |              $formatter = $this->getHelperSet()->get('formatter'); | 
| 43 | 43 | $filename = $this->getFilename(); | 
| 44 | 44 | $errorMessages = [ | 
| 45 | - 'Success!', | |
| 46 | -                               "Database seed class generated in: {$filename}", | |
| 47 | - ]; | |
| 45 | + 'Success!', | |
| 46 | +                                "Database seed class generated in: {$filename}", | |
| 47 | + ]; | |
| 48 | 48 | $formattedBlock = $formatter->formatBlock($errorMessages, 'info', true); | 
| 49 | 49 | $this->line($formattedBlock); | 
| 50 | 50 | } | 
| @@ -13,10 +13,10 @@ discard block | ||
| 13 | 13 | protected $description = 'Command to copy the migrations and/or the seeds to a remote host.'; | 
| 14 | 14 | |
| 15 | 15 | protected $ignoredFiles = [ | 
| 16 | - '..', | |
| 17 | - '.', | |
| 18 | - '.gitkeep', | |
| 19 | - ]; | |
| 16 | + '..', | |
| 17 | + '.', | |
| 18 | + '.gitkeep', | |
| 19 | + ]; | |
| 20 | 20 | |
| 21 | 21 | protected $uploadedFiles; | 
| 22 | 22 | |
| @@ -52,20 +52,20 @@ discard block | ||
| 52 | 52 |      { | 
| 53 | 53 | return [ | 
| 54 | 54 | [ | 
| 55 | - 'migrations', | |
| 56 | - 'm', | |
| 57 | - InputOption::VALUE_NONE, | |
| 58 | - 'Upload the migrations to a storage.', | |
| 59 | - null, | |
| 55 | + 'migrations', | |
| 56 | + 'm', | |
| 57 | + InputOption::VALUE_NONE, | |
| 58 | + 'Upload the migrations to a storage.', | |
| 59 | + null, | |
| 60 | 60 | ], | 
| 61 | 61 | [ | 
| 62 | - 'seeds', | |
| 63 | - 's', | |
| 64 | - InputOption::VALUE_NONE, | |
| 65 | - 'Upload the seeds to the remote host.', | |
| 66 | - null, | |
| 62 | + 'seeds', | |
| 63 | + 's', | |
| 64 | + InputOption::VALUE_NONE, | |
| 65 | + 'Upload the seeds to the remote host.', | |
| 66 | + null, | |
| 67 | 67 | ], | 
| 68 | - ]; | |
| 68 | + ]; | |
| 69 | 69 | } | 
| 70 | 70 | |
| 71 | 71 | //end getOptions() | 
| @@ -86,22 +86,22 @@ | ||
| 86 | 86 |      { | 
| 87 | 87 | $options = $this->option(); | 
| 88 | 88 |          switch ($options) { | 
| 89 | - case ($options['seeds'] === true) && ($options['migrations'] === true): | |
| 90 | -            if (!$this->upload('migrations')) { | |
| 91 | - return false; | |
| 92 | - } | |
| 89 | + case ($options['seeds'] === true) && ($options['migrations'] === true): | |
| 90 | +                if (!$this->upload('migrations')) { | |
| 91 | + return false; | |
| 92 | + } | |
| 93 | 93 | |
| 94 | -            return $this->upload('seeds'); | |
| 94 | +                return $this->upload('seeds'); | |
| 95 | 95 | |
| 96 | - case $options['migrations'] === true: | |
| 97 | - $this->commandOptions = 'migrations'; | |
| 96 | + case $options['migrations'] === true: | |
| 97 | + $this->commandOptions = 'migrations'; | |
| 98 | 98 | |
| 99 | -            return $this->upload('migrations'); | |
| 99 | +                return $this->upload('migrations'); | |
| 100 | 100 | |
| 101 | - case $options['seeds'] === true: | |
| 102 | - $this->commandOptions = 'seeds'; | |
| 101 | + case $options['seeds'] === true: | |
| 102 | + $this->commandOptions = 'seeds'; | |
| 103 | 103 | |
| 104 | -            return $this->upload('seeds'); | |
| 104 | +                return $this->upload('seeds'); | |
| 105 | 105 | } | 
| 106 | 106 | } | 
| 107 | 107 | |
| @@ -38,7 +38,7 @@ discard block | ||
| 38 | 38 |                  $this->line("\n"); | 
| 39 | 39 | $this->info(ucfirst($type)); | 
| 40 | 40 |                  foreach ($files as $file) { | 
| 41 | - $this->sectionMessage($type, $file.' uploaded.'); | |
| 41 | + $this->sectionMessage($type, $file . ' uploaded.'); | |
| 42 | 42 | } | 
| 43 | 43 | } | 
| 44 | 44 | |
| @@ -109,9 +109,9 @@ discard block | ||
| 109 | 109 | |
| 110 | 110 | private function upload($what) | 
| 111 | 111 |      { | 
| 112 | -        $localPath = Config::get('db-exporter.export_path.'.$what); | |
| 112 | +        $localPath = Config::get('db-exporter.export_path.' . $what); | |
| 113 | 113 | $dir = scandir($localPath); | 
| 114 | -        $remotePath = Config::get('db-exporter.remote.'.$what); | |
| 114 | +        $remotePath = Config::get('db-exporter.remote.' . $what); | |
| 115 | 115 |          $this->line("\n"); | 
| 116 | 116 | $this->info(ucfirst($what)); | 
| 117 | 117 | // Prepare the progress bar | 
| @@ -123,12 +123,12 @@ discard block | ||
| 123 | 123 | } | 
| 124 | 124 | |
| 125 | 125 | // Capture the uploaded files for displaying later | 
| 126 | - $this->uploadedFiles[$what][] = $remotePath.$file; | |
| 126 | + $this->uploadedFiles[$what][] = $remotePath . $file; | |
| 127 | 127 | |
| 128 | 128 | // Copy the files | 
| 129 | 129 | Storage::disk($this->getDiskName())->put( | 
| 130 | - $remotePath.$file, | |
| 131 | - $localPath.'/'.$file | |
| 130 | + $remotePath . $file, | |
| 131 | + $localPath . '/' . $file | |
| 132 | 132 | ); | 
| 133 | 133 | $progress->advance(); | 
| 134 | 134 | } |