-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from ucan-lab/develop
ver2.0.0 Release👏👏👏
- Loading branch information
Showing
13 changed files
with
289 additions
and
55 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
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
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
namespace UcanLab\LaravelDacapo\Console; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\File; | ||
|
||
/** | ||
* Class DacapoUninstallCommand | ||
*/ | ||
class DacapoUninstallCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'dacapo:uninstall'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Uninstall dacapo.'; | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
$this->uninstallDacapo(); | ||
} | ||
|
||
/** | ||
* Uninstall dacapo | ||
* | ||
* @return void | ||
*/ | ||
private function uninstallDacapo(): void | ||
{ | ||
$this->deleteSchemasDirectory(); | ||
$this->info('Deleted schemas directory.'); | ||
$this->info('Please delete dacapo composer package.'); | ||
$this->comment('composer remove --dev ucan-lab/laravel-dacapo'); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
private function deleteSchemasDirectory(): bool | ||
{ | ||
return File::deleteDirectory($this->getSchemasPath()); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
private function getSchemasPath(): string | ||
{ | ||
return database_path('schemas'); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace UcanLab\LaravelDacapo\Generator; | ||
|
||
use Illuminate\Support\Facades\Artisan; | ||
use Illuminate\Support\Facades\File; | ||
use UcanLab\LaravelDacapo\Migrations\Schema\Tables; | ||
|
||
class ModelTemplateGenerator | ||
{ | ||
private $tables; | ||
|
||
public function __construct(Tables $tables) | ||
{ | ||
$this->tables = $tables; | ||
} | ||
|
||
public function run(): void | ||
{ | ||
foreach ($this->tables as $table) { | ||
if (! $this->existsModel($table->getModelName())) { | ||
Artisan::call('make:model', [ | ||
'name' => $table->getModelName(), | ||
]); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
private function getModelPath(): string | ||
{ | ||
return app_path(); | ||
} | ||
|
||
private function existsModel(string $modelName): bool | ||
{ | ||
return File::exists($this->getModelPath() . '/' . $modelName . '.php'); | ||
} | ||
} |
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
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
Oops, something went wrong.