This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
atehnix
committed
Sep 6, 2018
1 parent
9e32c2f
commit dd1b5fa
Showing
3 changed files
with
15 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,14 @@ | |
/** | ||
* This file is part of laravel-stubs package. | ||
* | ||
* @author ATehnix <[email protected]> | ||
* @author Daniel Camargo <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ATehnix\LaravelStubs\Console; | ||
namespace ATehnix\LaravelStubs\Database; | ||
|
||
use Illuminate\Database\Migrations\MigrationCreator as BaseMigrationCreator; | ||
|
||
|
@@ -25,62 +26,13 @@ class MigrationCreator extends BaseMigrationCreator | |
protected function getStub($table, $create) | ||
{ | ||
if (is_null($table)) { | ||
return $this->getBlankStub($table, $create); | ||
} | ||
return ($create) ? $this->getCreateStub($table, $create) : $this->getUpdateStub($table, $create); | ||
} | ||
|
||
/** | ||
* Get blank stub | ||
* | ||
* @param $table | ||
* @param $create | ||
* @return string | ||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException | ||
*/ | ||
private function getBlankStub($table, $create) | ||
{ | ||
$blankStub = config('stubs.path') . '/migration.blank.stub'; | ||
if (!file_exists($blankStub)) { | ||
return parent::getStub($table, $create); | ||
} | ||
|
||
return $this->files->get($blankStub); | ||
} | ||
|
||
/** | ||
* Get create stub | ||
* | ||
* @param $table | ||
* @param $create | ||
* @return string | ||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException | ||
*/ | ||
private function getCreateStub($table, $create) | ||
{ | ||
$createStub = config('stubs.path') . '/migration.create.stub'; | ||
if (!file_exists($createStub)) { | ||
return parent::getStub($table, $create); | ||
} | ||
|
||
return $this->files->get($createStub); | ||
} | ||
|
||
/** | ||
* Get update stub | ||
* | ||
* @param $table | ||
* @param $create | ||
* @return string | ||
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException | ||
*/ | ||
private function getUpdateStub($table, $create) | ||
{ | ||
$updateStub = config('stubs.path') . '/migration.update.stub'; | ||
if (!file_exists($updateStub)) { | ||
return parent::getStub($table, $create); | ||
$stub = config('stubs.path') . '/migration.blank.stub'; | ||
} else { | ||
$stub = $create | ||
? config('stubs.path') . '/migration.create.stub' | ||
: config('stubs.path') . '/migration.update.stub'; | ||
} | ||
|
||
return $this->files->get($updateStub); | ||
return file_exists($stub) ? $this->files->get($stub) : parent::getStub($table, $create); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters