-
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.
- Loading branch information
Showing
6 changed files
with
107 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright 2021 - N'Guessan Kouadio Elisée ([email protected]) | ||
* @license MIT (https://opensource.org/licenses/MIT) | ||
* @link https://github.com/eliseekn/tinymvc | ||
*/ | ||
|
||
namespace Core\Console\Make; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputOption; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Create new model repository | ||
*/ | ||
class Repository extends Command | ||
{ | ||
protected static $defaultName = 'make:repository'; | ||
|
||
protected function configure() | ||
{ | ||
$this->setDescription('Create new model repository'); | ||
$this->addArgument('repository', InputArgument::REQUIRED|InputArgument::IS_ARRAY, 'The name of model repository table (separated by space if many)'); | ||
$this->addOption('namespace', null, InputOption::VALUE_OPTIONAL, 'Specify namespace (base: App\Database\Repositories)'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$repositories = $input->getArgument('repository'); | ||
|
||
foreach ($repositories as $repository) { | ||
list(, $class) = Make::generateClass($repository, 'repository', true, true); | ||
|
||
if (!Make::createRepository($repository, $input->getOption('namespace'))) { | ||
$output->writeln('<fg=yellow>Failed to create repository "' . Make::fixPluralTypo($class, true) . '"</fg>'); | ||
} | ||
|
||
$output->writeln('<info>repository "' . Make::fixPluralTypo($class, true) . '" has been created</info>'); | ||
} | ||
|
||
return Command::SUCCESS; | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright 2021 - N'Guessan Kouadio Elisée ([email protected]) | ||
* @license MIT (https://opensource.org/licenses/MIT) | ||
* @link https://github.com/eliseekn/tinymvc | ||
*/ | ||
|
||
namespace NAMESPACE; | ||
|
||
use App\Database\Models\MODELNAME; | ||
|
||
class CLASSNAME | ||
{ | ||
public static function findAllByColumn(string $column) | ||
{ | ||
return MODELNAME::findBy('column', $column)->latest()->getAll(); | ||
} | ||
} |