示例#1
0
 public function addImage($id, $attribute_name, $file)
 {
     $image = \ImageDriver::store(['file' => $file]);
     $item = $this->get($id);
     $item->{'images_' . $attribute_name}()->attach($image->id);
     return $image;
 }
示例#2
0
 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);
 }