public function removeImage($id, $attribute_name, $image_id) { $image = \ImageDriver::get($image_id); $item = $this->get($id); $item->{'images_' . $attribute_name}()->detach($image->id); \ImageDriver::delete($image_id); return $image; }
public function update($id, $data) { $definition = $this->get($id); if ($definition->type == 'image' && $data['file']) { $image = \ImageDriver::store(['file' => $data['file']]); $data['image_id'] = $image->id; } return parent::update($id, $data); }