protected function importing($data) { // Process Tags $tagIdList = array(); foreach ($data->tags as $tagData) { $tagIdList[] = $tagData->id; $tag = HailTag::get()->filter(array('HailID' => $tagData->id))->first(); if (!$tag) { $tag = new HailTag(); } $tag->importHailData($tagData); if (!$this->Tags()->byID($tag->ID)) { $this->Tags()->add($tag); } } // Remove old tags $this->Tags()->exclude('HailID', $this->HailID)->removeAll(); // Import face position data if (empty($data->focal_point)) { $this->FaceCentreX = -1; $this->FaceCentreY = -1; } else { $this->FaceCentreX = empty($data->focal_point->x) ? -1 : $data->focal_point->x; $this->FaceCentreY = empty($data->focal_point->y) ? -1 : $data->focal_point->y; } }
protected function importing($data) { // Process Tags $tagIdList = array(); foreach ($data->tags as $tagData) { $tagIdList[] = $tagData->id; $tag = HailTag::get()->filter(array('HailID' => $tagData->id))->first(); if (!$tag) { $tag = new HailTag(); } $tag->importHailData($tagData); if (!$this->Tags()->byID($tag->ID)) { $this->Tags()->add($tag); } } // Remove old tags $this->Tags()->exclude('HailID', $this->HailID)->removeAll(); $preview = $data->preview; $this->Url150Square = $preview->file_150_square_url; $this->Url500 = $preview->file_500_url; $this->Url500Square = $preview->file_500_square_url; $this->Url1000 = $preview->file_1000_url; $this->Url1000Square = $preview->file_1000_square_url; $this->Url2000 = $preview->file_2000_url; $this->Urloriginal = $preview->file_original_url; $this->OriginalWidth = $preview->original_width; $this->OriginalHeight = $preview->original_height; // Import face position data if (empty($preview->focal_point)) { $this->FaceCentreX = -1; $this->FaceCentreY = -1; } else { $this->FaceCentreX = empty($preview->focal_point->x) ? -1 : $preview->focal_point->x; $this->FaceCentreY = empty($previewata->focal_point->y) ? -1 : $preview->focal_point->y; } $this->importingColor('Background', $preview->colour_palette->background); $this->importingColor('Primary', $preview->colour_palette->primary); $this->importingColor('Secondary', $preview->colour_palette->secondary); $this->importingColor('Details', $preview->colour_palette->detail); }
private function processTags($data) { $tagIdList = array(); foreach ($data as $tagData) { $tagIdList[] = $tagData->id; // Find a matching HailTag or create an new one $tag = HailTag::get()->filter(array('HailID' => $tagData->id))->first(); if (!$tag) { $tag = new HailTag(); } // Update the Hail Tag $tag->importHailData($tagData); if (!$this->Tags()->byID($tag->ID)) { $this->Tags()->add($tag); } } // Remove old tag that are currently assigned to this article, // but have not been returned this time around if ($tagIdList) { $this->Tags()->exclude('HailID', $tagIdList)->removeAll(); } else { $this->Tags()->removeAll(); } }