Skip to content

Commit 388a670

Browse files
authored
Merge pull request #22 from mohammadRezaei1380/Feature_redis
Feature redis
2 parents 3ccc75a + 6262b5b commit 388a670

File tree

3 files changed

+20
-9
lines changed

3 files changed

+20
-9
lines changed

src/Commands/BaseCommand.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,15 @@ public function finalized(string $filenameWithPath, string $entityName, string $
104104

105105
$this->info("\"$entityName\" has been created.");
106106
}
107+
107108
public function checkEmpty(Collection $columns, string $tableName): void
108109
{
109110
if ($columns->isEmpty()) {
110111
$this->alert("Couldn't retrieve columns from table \"$tableName\"! Perhaps table's name is misspelled.");
111112
exit;
112113
}
113114
}
115+
114116
public function setChoice($choice): void
115117
{
116118
\config(['replacement.choice' => $choice]);
@@ -129,12 +131,14 @@ public function checkStrategyName()
129131
exit;
130132
}
131133
}
134+
132135
public function checkDatabasesExist()
133136
{
134-
$entityName=Str::singular(ucfirst(Str::camel($this->argument('table_name'))));
135-
$mysql ="App\Models\Repositories". "\\". $entityName. "\\"."MySql".$entityName."Repository.php";
136-
$redis ="App\Models\Repositories". "\\". $entityName. "\\"."Redis".$entityName."Repository.php";
137-
if(!file_exists($mysql) && !file_exists($redis)) {
137+
138+
$entityName = Str::singular(ucfirst(Str::camel($this->argument('table_name'))));
139+
$mysql = config('repository.path.namespace.repositories') . "\\" . $entityName . "\\" . "MySql" . $entityName . "Repository.php";
140+
$redis = config('repository.path.namespace.repositories') . "\\" . $entityName . "\\" . "Redis" . $entityName . "Repository.php";
141+
if (!(file_exists($mysql) && file_exists($redis))) {
138142
$this->alert("First create the class databases!!!");
139143
exit;
140144
}

src/Commands/MakeAll.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class MakeAll extends Command
1818
protected $signature = 'repository:make-all
1919
{--selected_db= : Main database}
2020
{--table_names= : Table names, separate names with comma}
21+
{--strategy_name= : strategy name}
2122
{--k|foreign-keys : Detect foreign keys}
2223
{--d|delete : Delete resource}
2324
{--f|force : Override/Delete existing classes}
@@ -36,12 +37,20 @@ class MakeAll extends Command
3637
*/
3738
public function handle()
3839
{
40+
41+
42+
$strategyNames = array("ClearableTemporaryCacheStrategy", "QueryCacheStrategy", "SingleKeyCacheStrategy", "TemporaryCacheStrategy");
43+
if (!in_array($this->option('strategy_name'), $strategyNames)) {
44+
$this->alert("This pattern strategy does not exist !!! ");
45+
exit;
46+
}
47+
3948
$this->selectedDb = $this->hasOption('selected_db') && $this->option('selected_db') ? $this->option('selected_db') : config('repository.default_db');
4049
$force = $this->option('force');
4150
$delete = $this->option('delete');
4251
$detectForeignKeys = $this->option('foreign-keys');
4352
$addToGit = $this->option('add-to-git');
44-
53+
$strategy=$this->option('strategy_name');
4554
if ($this->option('all-tables')) {
4655
$tableNames = $this->getAllTableNames()->pluck('TABLE_NAME');
4756
} else if ($this->option('table_names')) {
@@ -59,15 +68,14 @@ public function handle()
5968
'--force' => $force,
6069
'--add-to-git' => $addToGit
6170
];
62-
6371
$this->call('repository:make-entity', $arguments);
6472
$this->call('repository:make-enum', ['table_name' => $_tableName, '--delete' => $delete, '--force' => $force, '--add-to-git' => $addToGit]);
6573
$this->call('repository:make-factory', ['table_name' => $_tableName, '--delete' => $delete, '--force' => $force, '--add-to-git' => $addToGit]);
6674
$this->call('repository:make-resource', $arguments);
6775
$this->call('repository:make-interface-repository', $arguments);
6876
$this->call('repository:make-mysql-repository', $arguments);
69-
$this->call('repository:make-redis-repository', $arguments);
70-
$this->call('repository:make-repository', [...$arguments,'selected_db'=>$this->selectedDb]);
77+
$this->call('repository:make-redis-repository',[...$arguments,'strategy'=>$strategy]);
78+
$this->call('repository:make-repository', [...$arguments,'strategy'=>$strategy,'selected_db'=>$this->selectedDb]);
7179
}
7280
}
7381
}

src/Commands/MakeRedisRepository.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class MakeRedisRepository extends BaseCommand
3737
*/
3838
public function handle()
3939
{
40-
4140
$this->checkStrategyName();
4241
$this->setArguments();
4342

0 commit comments

Comments
 (0)