/** * Execute the console command. * * @return boolean */ public function handle() { if (empty($this->option('id')) && empty($this->option("name"))) { $this->warn('no --id or --name argument was passed, try --help'); return false; } /* @var $domain \AbuseIO\Models\Domain|null */ $domain = Domain::find($this->option("id")) ?: $this->findByName($this->option("name")); if (null !== $domain) { $this->table($this->headers, $this->transformDomainToTableBody($domain)); } else { $this->warn("No matching domain where found."); } return true; }
/** * Execute the console command. * * @return boolean */ public function handle() { if (empty($this->option('id'))) { $this->warn('The required id argument was not passed, try --help'); return false; } /** @var Domain|null $domain */ $domain = Domain::find($this->option('id')); if (null === $domain) { $this->error('Unable to find domain with this criteria'); return false; } if (!empty($this->option("contact"))) { /** @var User|null $user */ $user = User::find($this->option('contact')) ?: User::where('email', '=', $this->option("contact"))->first(); if (null === $user) { $this->error("Unable to find contact with this criteria"); return false; } $domain->contact()->associate($user); } if (!empty($this->option("name"))) { $domain->name = $this->option("name"); } if (!empty($this->option("enabled"))) { $domain->enabled = castStringToBool($this->option("enabled")); } $validation = Validator::make($domain->toArray(), Domain::updateRules($domain)); if ($validation->fails()) { foreach ($validation->messages()->all() as $message) { $this->warn($message); } $this->error('Failed to create the domain due to validation warnings'); return false; } $domain->save(); $this->info("Domain has been successfully updated"); return true; }
/** * {@inheritdoc } */ protected function getObjectByArguments() { return Domain::find($this->argument("id")); }
/** * {@inheritdoc}. */ protected function getModelFromRequest() { return Domain::find($this->argument('id')); }