-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleListenerCommand.php
More file actions
30 lines (22 loc) · 938 Bytes
/
Copy pathModuleListenerCommand.php
File metadata and controls
30 lines (22 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Str;
class ModuleListenerCommand extends Command
{
protected $signature = 'module:listener {module} {name}';
protected $description = 'Bir modüle listener sınıfı ekler';
public function handle(): void
{
$module = Str::studly($this->argument('module'));
$name = Str::studly($this->argument('name'));
$path = app_path("Modules/{$module}/Listeners/{$name}.php");
if (File::exists($path)) {
$this->error("Listener zaten var: {$name}");
return;
}
File::put($path, "<?php\n\nnamespace App\\Modules\\{$module}\\Listeners;\n\nclass {$name}\n{\n public function handle(\$event): void\n {\n // olay çözümü\n }\n}");
$this->info("✅ {$module} modülüne {$name} listener eklendi");
}
}