Completed
Pull Request — master (#9)
by
unknown
02:22
created

DeleteHost::handle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 0
1
<?php
2
3
namespace Spatie\ServerMonitor\Commands;
4
5
use Spatie\ServerMonitor\Models\Host;
6
7
class DeleteHost extends BaseCommand
8
{
9
    protected $signature = 'server-monitor:delete-host
10
                            {name : The host\'s name}';
11
12
    protected $description = 'Delete a host';
13
14
    public function handle()
15
    {
16
        $name = $this->argument('name');
17
18
        $host = Host::where('name', $name)->first();
19
20
        if(! $host) {
21
            return $this->error("Host with name '{$name}' not found.");
22
        }
23
24
        $host->delete();
25
26
        $this->info("{$name} deleted!");
27
    }
28
}
29