public function __construct($provider, $data) { $this->provider = $provider; $this->id = $data['id']; $this->name = $data['name']; $this->region = Region::create($data['region']); $this->sizeId = $data['size_slug']; $this->image = Image::create($data['image']); $this->kernel = Kernel::create($data['kernel']); foreach ($data['networks']['v4'] as $ip) { $ip['version'] = '4'; $this->ipAddresses[] = IpAddress::create($ip); } foreach ($data['networks']['v6'] as $ip) { $ip['version'] = '6'; $this->ipAddresses[] = IpAddress::create($ip); } if ($data['status'] == 'active') { $this->isRunning = true; } if ($data['status'] == 'archive') { $this->isDeleted = true; } }
public function getImages() { $apiImages = $this->sendRequest('get', 'images'); $images = []; foreach ($apiImages['images'] as $image) { $id = empty($image['slug']) ? $image['id'] : $image['slug']; $images[$id] = Image::create($image); } return $images; }