/** * Gets the host id from the DB using the host url and sets it to the * host id property * * @return void */ protected function getHostIdFromDatabase() { if ($this->getHost() === null) { return; } $parsedUrl = parse_url($this->getHost()); $host = Host::firstOrCreate(['host' => $parsedUrl['host'], 'port' => isset($parsedUrl['port']) ? $parsedUrl['port'] : '']); $this->hostId = $host->id; }