hlacos / attachment
This package is abandoned and no longer maintained.
No replacement package was suggested.
Laravel attachment bundle
dev-master
2015-02-14 12:09 UTC
Requires
- php: >=5.4.0
- illuminate/support: 4.2.*
This package is auto-updated.
Last update: 2020-02-13 12:22:14 UTC
README
Eloquent extension for store simply file attachments.
It's under development, not recommended for production use!
Installation
- add bundle to composer: "hlacos/attachment": "dev-master"
- composer install
- add service provider to the providers list: 'Hlacos\Attachment\AttachmentServiceProvider'
- php artisan migrate --package="hlacos/attachment"
- create directory: public/attachments
- let it write by the web server
Attachments storing in public/attachments directory. To override it:
- php artisan config:publish hlacos/attachment
- edit app/config/packages/hlacos/attachment.php
Usage
$attachment = new Attachment; $attachment->addFile($filename); $attachment->attachable()->associate($relatedModel); $attachment->save();
Override table
Extend Hlacos\Attachment\Attachment and set the $table attribute.
Set uploadable image required sizes
Extend Hlacos\Attachment\Attachment and set the $sizes array attribute. In the array sets the width of the required images;
Related models
You can set polymoprhic relations in the realted models.
public function attachment() { return $this->morphOne('Hlacos\Attachment\Attachment', 'attachable'); }
public function attachment() { return $this->morphMany('Hlacos\Attachment\Attachment', 'attachable'); }