imagina/imedia-module
最新稳定版本:10.0.0
Composer 安装命令:
composer require imagina/imedia-module
包简介
Imagina imedia laravel module
README 文档
README
Private Files Configurations
- The bucker must have the permissions configured correctly
- Read and write should be set only for the allowed user
Implementation with Modules
In the Entity (Models/Entity)
- Add Events
public array $dispatchesEventsWithBindings = [ 'created' => [['path' => 'Modules\Imedia\Events\CreateMedia']], 'creating' => [], 'updated' => [['path' => 'Modules\Imedia\Events\UpdateMedia']], 'updating' => [], 'deleting' => [['path' => 'Modules\Imedia\Events\DeleteMedia']], 'deleted' => [] ];
- Add the zones
/** * Media Fillable */ public $mediaFillable = [ 'mainimage' => 'single' ];
- Add relation:
/** * Relation Media * Make the Many To Many Morph */ public function files() { if (isModuleEnabled('Imedia')) { return app(\Modules\Imedia\Relations\FilesRelation::class)->resolve($this); } return new \Imagina\Icore\Relations\EmptyRelation(); }
In Transformer (Transformers/EntityTransformer)
- Add relation with files
//Implementation with Media return [ 'files' => $this->whenLoaded('files', fn() => $this->files->byZones($this->mediaFillable, $this)), ];
Endpoint | Attributes Example
- To Media single , add zone and file id.
attributes[medias_single][$zone] = $fileId
Example: Zone = mainimage
attributes[medias_single][mainimage] = 1
- To Media gallery, add zone and files array ids.
attributes[medias_multi][$zone][files][] = $fileId
Example: Zone = gallery
attributes[medias_multi][gallery][files][] = 1
attributes[medias_multi][gallery][files][] = 2
统计信息
- 总下载量: 26
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-08-29