hlacos/attachment5
最新稳定版本:0.1.5
Composer 安装命令:
composer require hlacos/attachment5
包简介
Attachment bundle for laravel 5.1
README 文档
README
Laravel 5 bundle for store simply file attachments.
It's under development, not recommended for production use!
Installation
- add bundle to composer: "hlacos/attachment5": "dev-master"
- composer install / update
- add service provider to the providers list: 'Hlacos\Attachment5\Attachment5ServiceProvider'
- publish config and migration: php artisan vendor:publish --provider="Hlacos\Attachment5\Attachment5ServiceProvider"
- php artisan migrate
- create directory: public/attachments
- let it write by the web server
Attachments storing in public/attachments directory. To override it:
- edit config/attachment5.php
Usage
$attachment = new Attachment; $attachment->addFile($filename); $attachment->attachable()->associate($relatedModel); $attachment->save();
Override table
Extend Hlacos\Attachment5\Models\Attachment and set the $table attribute.
Set uploadable image required sizes
Extend Hlacos\Attachment5\Models\Attachment and set the $sizes array attribute. In the array sets the width of the required images;
Set max size of the original image
Extend Hlacos\Attachment5\Models\Attachment and set the $originalMaxSize string attribute.
Related models
You can set polymoprhic relations in the realted models.
public function attachment() {
return $this->morphOne('Hlacos\Attachment5\Models\Attachment', 'attachable');
}
public function attachment() {
return $this->morphMany('Hlacos\Attachment5\Models\Attachment', 'attachable');
}
Contributions
Thanks to David Beyaty (https://github.com/hatja) for the gif resize implementation.
统计信息
- 总下载量: 4.14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-04-03