2017 © Pedro Peláez
 

library attachment

Laravel attachment bundle

image

hlacos/attachment

Laravel attachment bundle

  • Saturday, February 14, 2015
  • by Hlacos
  • Repository
  • 1 Watchers
  • 2 Stars
  • 43 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Attachment bundle

Eloquent extension for store simply file attachments., (*1)

It's under development, not recommended for production use!, (*2)

Installation

  1. add bundle to composer: "hlacos/attachment": "dev-master"
  2. composer install
  3. add service provider to the providers list: 'Hlacos\Attachment\AttachmentServiceProvider'
  4. php artisan migrate --package="hlacos/attachment"
  5. create directory: public/attachments
  6. let it write by the web server

Attachments storing in public/attachments directory. To override it:, (*3)

  1. php artisan config:publish hlacos/attachment
  2. 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., (*4)

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;, (*5)

Related models

You can set polymoprhic relations in the realted models., (*6)

public function attachment() {
    return $this->morphOne('Hlacos\Attachment\Attachment', 'attachable');
}
public function attachment() {
    return $this->morphMany('Hlacos\Attachment\Attachment', 'attachable');
}

The Versions

14/02 2015

dev-master

9999999-dev

Laravel attachment bundle

  Sources   Download

MIT

The Requires

 

laravel eloquent attachment