-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update .travis.yml * Revert "Update .travis.yml" This reverts commit 6c54da4. * Update GeneratorTest.php * feat: Hard Refactor (#29) * Updated stub-test * New Generators * Added dependency Support * Removed unused param & added setData * commands depends on new generators Old generator has been deprecated * Updated PHPUnit test suite * ControllerGenerator + tests * FactoryGenerator + test * ModelGenerator + test * RequestGenerator + test * ResourceGenerator + test * RouteGenerator + tests * fix: typo in ModelGenerator * TestGenerator + test * Stub + test * updated .gitignore * Php-cs-fixer Co-authored-by: Andrea Civita <[email protected]> * Namespace Added to Factory Stub (#33) (#36) Co-authored-by: Max VanRay <[email protected]> * - Optimized all the stubs and docblocks (#35) * - Optimized all the stubs and docblocks * Add Import to Model Stub * Remove the import from the Model Stub Clean up the imports on the Controller Stub Related to issue #32 Co-authored-by: [email protected] <[email protected]> Co-authored-by: Andrea Civita <[email protected]> Co-authored-by: Max VanRay <[email protected]> Co-authored-by: Max VanReynegom <[email protected]>
- Loading branch information
1 parent
199c06e
commit 6e32531
Showing
27 changed files
with
965 additions
and
81 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,7 @@ | |
vendor/ | ||
composer.lock | ||
.php_cs.cache | ||
.phpunit.result.cache | ||
.phpunit.result.cache | ||
app/ | ||
database/ | ||
routes/ |
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,65 @@ | ||
<?php | ||
|
||
namespace AndreaCivita\ApiCrudGenerator\Core\Generators; | ||
|
||
use AndreaCivita\ApiCrudGenerator\Core\Stub; | ||
use AndreaCivita\ApiCrudGenerator\Interfaces\Generator; | ||
use Illuminate\Filesystem\Filesystem; | ||
|
||
class ControllerGenerator implements Generator | ||
{ | ||
/** | ||
* @var string $name | ||
*/ | ||
protected $name; | ||
|
||
/** | ||
* @var string $table | ||
*/ | ||
protected $table; | ||
|
||
/** | ||
* @var Filesystem $fileSystem | ||
*/ | ||
protected $fileSystem; | ||
|
||
/** | ||
* @var Stub $stub | ||
*/ | ||
protected $stub; | ||
|
||
/** | ||
* @param Stub $stub | ||
*/ | ||
public function __construct(Stub $stub) | ||
{ | ||
$this->stub = $stub; | ||
$this->fileSystem = $this->stub->getFilesystemInstance(); | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @param string $table | ||
* @return ControllerGenerator | ||
*/ | ||
public function setData(string $name, string $table): ControllerGenerator | ||
{ | ||
$this->name = $name; | ||
$this->table = $table; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function generate() | ||
{ | ||
$content = $this->stub->parseStub('Controller', $this->name, ['table' => $this->table]); | ||
|
||
if (!$this->fileSystem->exists("app/Http/Controllers/")) { | ||
$this->fileSystem->makeDirectory("app/Http/Controllers/", 0755, true); | ||
} | ||
|
||
return $this->fileSystem->put("app/Http/Controllers/{$this->name}Controller.php", $content); | ||
} | ||
} |
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,58 @@ | ||
<?php | ||
|
||
namespace AndreaCivita\ApiCrudGenerator\Core\Generators; | ||
|
||
use AndreaCivita\ApiCrudGenerator\Core\Stub; | ||
use AndreaCivita\ApiCrudGenerator\Interfaces\Generator; | ||
use Illuminate\Filesystem\Filesystem; | ||
|
||
class FactoryGenerator implements Generator | ||
{ | ||
/** | ||
* @var string $name | ||
*/ | ||
protected $name; | ||
|
||
|
||
/** | ||
* @var Filesystem $fileSystem | ||
*/ | ||
protected $fileSystem; | ||
|
||
/** | ||
* @var Stub $stub | ||
*/ | ||
protected $stub; | ||
|
||
/** | ||
* @param Stub $stub | ||
*/ | ||
public function __construct(Stub $stub) | ||
{ | ||
$this->stub = $stub; | ||
$this->fileSystem = $this->stub->getFilesystemInstance(); | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* @return $this | ||
*/ | ||
public function setData(string $name): FactoryGenerator | ||
{ | ||
$this->name = $name; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function generate() | ||
{ | ||
$content = $this->stub->parseStub('Factory', $this->name); | ||
|
||
if (!$this->fileSystem->exists("database/factories/")) { | ||
$this->fileSystem->makeDirectory("database/factories/", 0755, true); | ||
} | ||
return $this->fileSystem->put("database/factories/{$this->name}Factory.php", $content); | ||
} | ||
} |
Oops, something went wrong.