Last active
January 19, 2016 14:58
-
-
Save martinbean/4c263347e7d596cb714a to your computer and use it in GitHub Desktop.
Laravel repository make command.
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
<?php | |
namespace DummyNamespace; | |
class DummyClass extends Repository | |
{ | |
// | |
} |
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
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Console\GeneratorCommand; | |
class RepositoryMakeCommand extends GeneratorCommand | |
{ | |
/** | |
* The console command name. | |
* | |
* @var string | |
*/ | |
protected $name = 'make:repository'; | |
/** | |
* The console command description. | |
* | |
* @var string | |
*/ | |
protected $description = 'Create a new repository class'; | |
/** | |
* The type of class being generated. | |
* | |
* @var string | |
*/ | |
protected $type = 'Repository'; | |
/** | |
* Get the stub file for the generator. | |
* | |
* @return string | |
*/ | |
protected function getStub() | |
{ | |
return __DIR__.'/../stubs/repository.stub'; | |
} | |
/** | |
* Get the default namespace for the class. | |
* | |
* @param string $rootNamespace | |
* @return string | |
*/ | |
protected function getDefaultNamespace($rootNamespace) | |
{ | |
return $rootNamespace.'\Repositories'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add the command class to your app/Console/Commands directory, and the stub file to app/Console/stubs. Then add the command to your app/Console/Kernel.php file:
Usage from the command line:
Be sure to update the root namespace (
App
) to your application’s if you need to.