1 | <?php |
||
2 | |||
3 | namespace Salah3id\Domains\Commands; |
||
4 | |||
5 | use Illuminate\Console\Command; |
||
6 | use Illuminate\Support\Str; |
||
7 | use Symfony\Component\Console\Input\InputArgument; |
||
8 | |||
9 | class UseCommand extends Command |
||
10 | { |
||
11 | /** |
||
12 | * The console command name. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $name = 'domain:use'; |
||
17 | |||
18 | /** |
||
19 | * The console command description. |
||
20 | * |
||
21 | * @var string |
||
22 | */ |
||
23 | protected $description = 'Use the specified domain.'; |
||
24 | |||
25 | /** |
||
26 | * Execute the console command. |
||
27 | */ |
||
28 | public function handle(): int |
||
29 | { |
||
30 | $domain = Str::studly($this->argument('domain')); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
31 | |||
32 | if (!$this->laravel['domains']->has($domain)) { |
||
33 | $this->error("Domain [{$domain}] does not exists."); |
||
34 | |||
35 | return E_ERROR; |
||
36 | } |
||
37 | |||
38 | $this->laravel['domains']->setUsed($domain); |
||
39 | |||
40 | $this->info("Domain [{$domain}] used successfully."); |
||
41 | |||
42 | return 0; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * Get the console command arguments. |
||
47 | * |
||
48 | * @return array |
||
49 | */ |
||
50 | protected function getArguments() |
||
51 | { |
||
52 | return [ |
||
53 | ['domain', InputArgument::REQUIRED, 'The name of domain will be used.'], |
||
54 | ]; |
||
55 | } |
||
56 | } |
||
57 |