/** * Create new media item * @param array $data * @return mixed */ public function create($data) { $media = new Media(); $media->path = array_get($data, 'path'); $media->field_id = array_get($data, 'field_id'); $media->entry_id = (int) array_get($data, 'entry_id'); $media->parent_id = (int) array_get($data, 'parent_id'); $media->save(); return new MediaEntity($media->toArray()); }
/** * Create new gallery * @param array $data */ public function create($data) { $gallery = new Media(); $gallery->entry_id = (int) array_get($data, 'entry_id'); $gallery->field_id = array_get($data, 'field_id'); $gallery->title = array_get($data, 'title'); $gallery->description = array_get($data, 'description'); $gallery->type = 'collection'; $gallery->save(); return new GalleryEntity($gallery->toArray()); }