A Laravel 4 package for adding content managed 'downloads' to a site
fbf/laravel-downloads is a Laravel package for a laravel 4 package for adding content managed 'downloads' to a site.
It currently has 3 GitHub stars and 107 downloads on Packagist.
Install it with composer require fbf/laravel-downloads.
Discover more Laravel packages by fbf
or browse all Laravel packages to compare alternatives.
Last updated
A Laravel 4 package for adding content managed 'downloads' to a site
Add the following to you composer.json file
"fbf/laravel-downloads": "dev-master"
Run
composer update
Add the following to app/config/app.php
'Fbf\LaravelDownloads\LaravelDownloadsServiceProvider'
Publish the config
php artisan config:publish fbf/laravel-downloads
Run the migration
php artisan migrate --package="fbf/laravel-downloads"
Create the relevant image upload directories that you specify in your config, e.g.
public/uploads/packages/fbf/laravel-downloads/downloads
public/uploads/packages/fbf/laravel-downloads/images/original
public/uploads/packages/fbf/laravel-downloads/images/resized
In your views you can do something like the following:
<p class="download--{{ strtolower($download->extension) }}">
<a href="{{ $download->getRelativePath() }}" title="{{ $download->title }}">
<img src="{{ $download->getImageRelativePath('resized') }}" alt="{{ $download->title }}" width="{{ $download->getImageWidth('resized') }}" height="{{ $download->getImageHeight('resized') }}" />
Download our {{ $download->title }}
</a>
[{{ $download->extension }}, {{ $download->human_readable_filesize }}]
</p>
You can use the excellent Laravel Administrator package by frozennode to administer your images.
http://administrator.frozennode.com/docs/installation
A ready-to-use model config file for the Download model (downloads.php) is provided in the src/config/administrator directory of the package, which you can copy into the app/config/administrator directory (or whatever you set as the model_config_path in the administrator config file).