| @@ 11-66 (lines=56) @@ | ||
| 8 | use Symfony\Component\Console\Input\InputArgument; |
|
| 9 | use File; |
|
| 10 | ||
| 11 | class CreateControllerCommand extends Command |
|
| 12 | { |
|
| 13 | /** |
|
| 14 | * The name and signature of the console command. |
|
| 15 | * |
|
| 16 | * @var string |
|
| 17 | */ |
|
| 18 | protected $signature = 'bantenprov:create-controller'; |
|
| 19 | ||
| 20 | /** |
|
| 21 | * The console command description. |
|
| 22 | * |
|
| 23 | * @var string |
|
| 24 | */ |
|
| 25 | protected $description = 'Create controller'; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * Create a new command instance. |
|
| 29 | * |
|
| 30 | * @return void |
|
| 31 | */ |
|
| 32 | ||
| 33 | protected $stubsController = [ |
|
| 34 | 'controllers' => [ |
|
| 35 | 'BedController.stub', |
|
| 36 | 'InfoKamarController.stub', |
|
| 37 | 'KelasController.stub', |
|
| 38 | 'RuangController.stub' |
|
| 39 | ] |
|
| 40 | ]; |
|
| 41 | ||
| 42 | ||
| 43 | ||
| 44 | public function __construct() |
|
| 45 | { |
|
| 46 | parent::__construct(); |
|
| 47 | ||
| 48 | } |
|
| 49 | ||
| 50 | protected function controllerViewCreate() |
|
| 51 | { |
|
| 52 | ||
| 53 | foreach($this->stubsController['controllers'] as $stub) |
|
| 54 | { |
|
| 55 | File::put(base_path('app/Http/Controllers/').str_replace('stub','php',$stub),File::get(__DIR__.'/../stubs/Controllers/'.$stub)); |
|
| 56 | } |
|
| 57 | ||
| 58 | } |
|
| 59 | ||
| 60 | ||
| 61 | public function handle() |
|
| 62 | { |
|
| 63 | $this->controllerViewCreate(); |
|
| 64 | $this->info('Create controller success'); |
|
| 65 | } |
|
| 66 | } |
|
| 67 | ||
| @@ 11-51 (lines=41) @@ | ||
| 8 | use Symfony\Component\Console\Input\InputArgument; |
|
| 9 | use File; |
|
| 10 | ||
| 11 | class CreateModelCommand extends Command |
|
| 12 | { |
|
| 13 | ||
| 14 | protected $signature = 'bantenprov:create-model'; |
|
| 15 | ||
| 16 | ||
| 17 | protected $description = 'Create model'; |
|
| 18 | ||
| 19 | protected $stubsModel = [ |
|
| 20 | 'models' => [ |
|
| 21 | 'Kelasrawat.stub', |
|
| 22 | 'Ruangrawat.stub', |
|
| 23 | 'Tempattidur.stub' |
|
| 24 | ] |
|
| 25 | ]; |
|
| 26 | ||
| 27 | ||
| 28 | ||
| 29 | public function __construct() |
|
| 30 | { |
|
| 31 | parent::__construct(); |
|
| 32 | ||
| 33 | } |
|
| 34 | ||
| 35 | protected function modelViewCreate() |
|
| 36 | { |
|
| 37 | ||
| 38 | foreach($this->stubsModel['models'] as $stub) |
|
| 39 | { |
|
| 40 | File::put(base_path('app/').str_replace('stub','php',$stub),File::get(__DIR__.'/../stubs/Models/'.$stub)); |
|
| 41 | } |
|
| 42 | ||
| 43 | } |
|
| 44 | ||
| 45 | ||
| 46 | public function handle() |
|
| 47 | { |
|
| 48 | $this->modelViewCreate(); |
|
| 49 | $this->info('Create model success'); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||