|
2 | 2 |
|
3 | 3 | namespace Eghamat24\DatabaseRepository\Commands; |
4 | 4 |
|
5 | | -use Illuminate\Container\Container; |
6 | 5 | use Illuminate\Support\Collection; |
7 | 6 | use Illuminate\Console\Command; |
8 | | -use Eghamat24\DatabaseRepository\CustomMySqlQueries; |
9 | 7 | use Illuminate\Support\Str; |
10 | 8 |
|
11 | | -class BaseCommand extends Command |
| 9 | +abstract class BaseCommand extends Command |
12 | 10 | { |
13 | | -// use CustomMySqlQueries; |
14 | 11 | public string $selectedDb; |
15 | 12 | public string $tableName; |
16 | 13 | public string $detectForeignKeys; |
@@ -74,7 +71,7 @@ public function setArguments() |
74 | 71 | public function checkDelete(string $filenameWithPath, string $entityName, string $objectName): void |
75 | 72 | { |
76 | 73 | if (file_exists($filenameWithPath) && $this->option('delete')) { |
77 | | - unlink($filenameWithPath); |
| 74 | + \unlink($filenameWithPath); |
78 | 75 | $this->info("$objectName '$entityName' has been deleted."); |
79 | 76 | } |
80 | 77 | } |
@@ -125,19 +122,25 @@ public function getChoice(): null|string |
125 | 122 |
|
126 | 123 | public function checkStrategyName() |
127 | 124 | { |
128 | | - $strategyNames = array("ClearableTemporaryCacheStrategy", "QueryCacheStrategy", "SingleKeyCacheStrategy", "TemporaryCacheStrategy"); |
| 125 | + $strategyNames = [ |
| 126 | + 'ClearableTemporaryCacheStrategy', |
| 127 | + 'QueryCacheStrategy', |
| 128 | + 'SingleKeyCacheStrategy', |
| 129 | + 'TemporaryCacheStrategy' |
| 130 | + ]; |
| 131 | + |
129 | 132 | if (!in_array($this->argument('strategy'), $strategyNames)) { |
130 | | - $this->alert("This pattern strategy does not exist !!! "); |
| 133 | + $this->alert('This pattern strategy does not exist !!! '); |
131 | 134 | exit; |
132 | 135 | } |
133 | 136 | } |
134 | 137 |
|
135 | 138 | public function checkDatabasesExist() |
136 | 139 | { |
137 | | - |
138 | 140 | $entityName = Str::singular(ucfirst(Str::camel($this->argument('table_name')))); |
139 | | - $mysql = config('repository.path.relative.repositories') . DIRECTORY_SEPARATOR . $entityName . DIRECTORY_SEPARATOR . "MySql" . $entityName . "Repository.php"; |
140 | | - $redis = config('repository.path.relative.repositories') . DIRECTORY_SEPARATOR . $entityName . DIRECTORY_SEPARATOR . "Redis" . $entityName . "Repository.php"; |
| 141 | + $mysql = config('repository.path.relative.repositories') . DIRECTORY_SEPARATOR . $entityName . DIRECTORY_SEPARATOR . 'MySql' . $entityName . 'Repository.php'; |
| 142 | + $redis = config('repository.path.relative.repositories') . DIRECTORY_SEPARATOR . $entityName . DIRECTORY_SEPARATOR . 'Redis' . $entityName . 'Repository.php'; |
| 143 | + |
141 | 144 | if (!(file_exists($mysql) && file_exists($redis))) { |
142 | 145 | $this->alert("First create the class databases!!!"); |
143 | 146 | exit; |
|
0 commit comments