forked from azishapidin/indoregion
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add doc and change Readme for support publish on lumen
- Loading branch information
cacing69
committed
Aug 24, 2019
1 parent
13fe785
commit 69fb90a
Showing
2 changed files
with
128 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<?php | ||
/* | ||
* This file is part of the IndoRegion package. | ||
* | ||
* (c) Ibnul Mutaki <cacing69 | [email protected]> | ||
* | ||
*/ | ||
|
||
namespace AzisHapidin\IndoRegion; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\File; | ||
|
||
class IndoRegionPublishCommand extends Command | ||
{ | ||
/** | ||
* The console command signature. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'indoregion:publish'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Publish IndoRegion assets from vendor packages'; | ||
|
||
/** | ||
* Compatiblity for Lumen 5.5. | ||
* | ||
* @return void | ||
*/ | ||
public function handle() | ||
{ | ||
$this->fire(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return void | ||
*/ | ||
public function fire() | ||
{ | ||
$this->publishModels(); | ||
$this->publishMigrations(); | ||
$this->publishSeeds(); | ||
|
||
$this->info("Publishing IndoRegion complete"); | ||
} | ||
|
||
|
||
/** | ||
* Publish the directory to the given directory. | ||
* | ||
* @param string $from | ||
* @param string $to | ||
* @return void | ||
*/ | ||
protected function publishDirectory($from , $to) | ||
{ | ||
$exclude = array('..' , '.' , '.DS_Store'); | ||
$source = array_diff(scandir($from) , $exclude); | ||
|
||
foreach ($source as $item) { | ||
$this->info("Copying into : " . $to . $item); | ||
File::copy($from . $item , $to . $item); | ||
} | ||
} | ||
|
||
/** | ||
* Publish model. | ||
* | ||
* @return void | ||
*/ | ||
protected function publishModels() | ||
{ | ||
$this->publishDirectory(__DIR__.'/database/models/', app()->path()."/Models/"); | ||
} | ||
|
||
/** | ||
* Publish migrations. | ||
* | ||
* @return void | ||
*/ | ||
protected function publishMigrations() | ||
{ | ||
$this->publishDirectory(__DIR__.'/database/migrations/', app()->databasePath()."/migrations/"); | ||
} | ||
|
||
/** | ||
* Publish seeds. | ||
* | ||
* @return void | ||
*/ | ||
protected function publishSeeds() | ||
{ | ||
$this->publishDirectory(__DIR__.'/database/seeds/', app()->databasePath()."/seeds/"); | ||
} | ||
} |