Skip to content

Feature redis #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Commands/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ public function finalized(string $filenameWithPath, string $entityName, string $

$this->info("\"$entityName\" has been created.");
}

public function checkEmpty(Collection $columns, string $tableName): void
{
if ($columns->isEmpty()) {
$this->alert("Couldn't retrieve columns from table \"$tableName\"! Perhaps table's name is misspelled.");
exit;
}
}

public function setChoice($choice): void
{
\config(['replacement.choice' => $choice]);
Expand All @@ -129,12 +131,14 @@ public function checkStrategyName()
exit;
}
}

public function checkDatabasesExist()
{
$entityName=Str::singular(ucfirst(Str::camel($this->argument('table_name'))));
$mysql ="App\Models\Repositories". "\\". $entityName. "\\"."MySql".$entityName."Repository.php";
$redis ="App\Models\Repositories". "\\". $entityName. "\\"."Redis".$entityName."Repository.php";
if(!file_exists($mysql) && !file_exists($redis)) {

$entityName = Str::singular(ucfirst(Str::camel($this->argument('table_name'))));
$mysql = config('repository.path.namespace.repositories') . "\\" . $entityName . "\\" . "MySql" . $entityName . "Repository.php";
$redis = config('repository.path.namespace.repositories') . "\\" . $entityName . "\\" . "Redis" . $entityName . "Repository.php";
if (!(file_exists($mysql) && file_exists($redis))) {
$this->alert("First create the class databases!!!");
exit;
}
Expand Down
16 changes: 12 additions & 4 deletions src/Commands/MakeAll.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class MakeAll extends Command
protected $signature = 'repository:make-all
{--selected_db= : Main database}
{--table_names= : Table names, separate names with comma}
{--strategy_name= : strategy name}
{--k|foreign-keys : Detect foreign keys}
{--d|delete : Delete resource}
{--f|force : Override/Delete existing classes}
Expand All @@ -36,12 +37,20 @@ class MakeAll extends Command
*/
public function handle()
{


$strategyNames = array("ClearableTemporaryCacheStrategy", "QueryCacheStrategy", "SingleKeyCacheStrategy", "TemporaryCacheStrategy");
if (!in_array($this->option('strategy_name'), $strategyNames)) {
$this->alert("This pattern strategy does not exist !!! ");
exit;
}

$this->selectedDb = $this->hasOption('selected_db') && $this->option('selected_db') ? $this->option('selected_db') : config('repository.default_db');
$force = $this->option('force');
$delete = $this->option('delete');
$detectForeignKeys = $this->option('foreign-keys');
$addToGit = $this->option('add-to-git');

$strategy=$this->option('strategy_name');
if ($this->option('all-tables')) {
$tableNames = $this->getAllTableNames()->pluck('TABLE_NAME');
} else if ($this->option('table_names')) {
Expand All @@ -59,15 +68,14 @@ public function handle()
'--force' => $force,
'--add-to-git' => $addToGit
];

$this->call('repository:make-entity', $arguments);
$this->call('repository:make-enum', ['table_name' => $_tableName, '--delete' => $delete, '--force' => $force, '--add-to-git' => $addToGit]);
$this->call('repository:make-factory', ['table_name' => $_tableName, '--delete' => $delete, '--force' => $force, '--add-to-git' => $addToGit]);
$this->call('repository:make-resource', $arguments);
$this->call('repository:make-interface-repository', $arguments);
$this->call('repository:make-mysql-repository', $arguments);
$this->call('repository:make-redis-repository', $arguments);
$this->call('repository:make-repository', [...$arguments,'selected_db'=>$this->selectedDb]);
$this->call('repository:make-redis-repository',[...$arguments,'strategy'=>$strategy]);
$this->call('repository:make-repository', [...$arguments,'strategy'=>$strategy,'selected_db'=>$this->selectedDb]);
}
}
}
1 change: 0 additions & 1 deletion src/Commands/MakeRedisRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ class MakeRedisRepository extends BaseCommand
*/
public function handle()
{

$this->checkStrategyName();
$this->setArguments();

Expand Down