Download the PHP package artesaos/attacher without Composer
On this page you can find all versions of the php package artesaos/attacher. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package attacher
Attacher - Pictures attachment tool for Laravel
Upload for S3, Copy, Local, Anything, Manipulate and Attach Images in your Models
Current Build Status
Statistics
Tips
Installation
1 - Dependency
The first step is using composer to install the package and automatically update your composer.json
file, you can do this by running:
or manually update your composer.json
file
2 - Provider
You need to update your application configuration in order to register the package so it can be loaded by Laravel, just update your config/app.php
file adding the following code at the end of your 'providers'
section:
3 - Facade
Optional. You do not need to register the Facade of Attacher, but if you want to have access to some shortcuts feel free to use it.
In order to use the Attacher
facade, you need to register it on the config/app.php
file, you can do that the following way:
3.1 - Facade API
4 - Configuration
Run in your console php artisan vendor:publish
, now you have 3 new files, config/attacher.php
, config/flysystem.php
and database/migrations/2015_03_28_000000_create_attacher_images_table.php
Attacher need graham-campbell/flysystem Don't worry, Attacher registers the flysystem service automatically for you.
In the config/app.php
file, you can configure the destination path and the styles guides to manipulate the images.
Usage
The usage is very simple.
The image destination information are in flysystem configuration file config/flysystem.php
there you define which provider to use for uploading.
1 - Basic
1.1 - Using Styles Guide
Using a specific guide style to manipulate the images:
It is possible to change the style setted in config/attacher.php, by passing an array keyed by the style guide and the style that you wish to change. The array values should be Closure instances which receive the \Intervention\Image\Image:
Or use dot notation to change style:
2 - Traits
Attacher provides you two traits to facilitate the creation of galleries/collections of images linked to other objects using the technique morphMany
and morphOne
2.1 - HasImages
Bond with many images
The method addImage() has the same attributes of the method setupFile() of the AttachModel:
2.2 - HasImage [WIP]
Link to an image
The method addImage() has the same attributes of the method setupFile() of the AttachModel:
3 - Setting a Image Model Type
Sometimes you may need to specify a type of image model. For example, when a product there are images for listing and images for gallery. To do so, just pass additional third argument to the method:
Author
All versions of attacher with dependencies
intervention/image Version ~2.3
graham-campbell/flysystem Version ^3.0