Package Data | |
---|---|
Maintainer Username: | andrewelkins |
Package Create Date: | 2013-05-15 |
Package Last Update: | 2015-02-11 |
Home Page: | |
Language: | JavaScript |
License: | MIT |
Last Refreshed: | 2024-11-10 15:02:46 |
Package Statistics | |
---|---|
Total Downloads: | 1,309 |
Monthly Downloads: | 12 |
Daily Downloads: | 0 |
Total Stars: | 102 |
Total Watchers: | 8 |
Total Forks: | 26 |
Total Open Issues: | 6 |
Cabinet is a file upload package for Laravel 4.
Cabinet is a package that allows easy upload of files and images.
In the require
key of composer.json
file add the following:
For use with Laravel 4.1.x
"andrewelkins/cabinet": "1.0.x"
For use with Laravel 4.2.x
"andrewelkins/cabinet": "1.1.x"
Run the Composer update command
$ composer update
In your config/app.php
add 'Andrew13\Cabinet\CabinetServiceProvider'
to the end of the $providers
array
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
...
'Andrew13\Cabinet\CabinetServiceProvider',
),
At the end of config/app.php
add 'Cabinet' => 'Andrew13\Cabinet\CabinetFacade'
to the $aliases
array
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
...
'Cabinet' => 'Andrew13\Cabinet\CabinetFacade',
),
Now generate the Cabinet migration:
$ php artisan cabinet:migration
It will generate the <timestamp>_cabinet_setup_uploads_table.php
migration. You may now run it with the artisan migrate command:
$ php artisan migrate
It will setup a table containing filename
, directory_path
, extension
, user_id
and deleted_at
fields, which are the default fields needed for Cabinet use.
Create an upload model in app/models/Upload.php
:
<?php
use Andrew13\Cabinet\CabinetUpload;
class Upload extends CabinetUpload {
protected $softDelete = true;
}
CabinetUpload
class will take care of all the default upload behavior. This can be extended in your Upload model.
Least, you can dump a default controller and the default routes for Cabinet.
$ php artisan cabinet:controller
$ php artisan cabinet:routes
Don't forget to dump composer autoload
$ composer dump-autoload
In order to use the js/css/images you'll need to publish the assets.
$ php artisan asset:publish andrewelkins/cabinet
And you are ready to go.
Access http://localhost/upload
to upload a file. It is highly suggested to put some auth protection on the uploads.
To change the controller name when dumping the default controller template you can use the --name option.
$ php artisan cabinet:controller --name Uploader
Will result in UploaderController
Then, when dumping the routes, you should use the --controller option to match the existing controller.
$ php artisan confide:routes --controller Uploader
First, publish the config files:
$ php artisan config:publish andrewelkins/cabinet
Then edit the view names in app/config/packages/andrewelkins/confide/config.php
.
Further, you can change the location of the uploads, type of upload files, and many more options!
If you want to generate a RESTful controller you can use the additional --restful
or -r
option.
$ php artisan cabinet:controller --restful
Will result in a RESTful controller
Then, when dumping the routes, you should use the --restful option to match the existing controller.
$ php artisan cabinet:routes --restful
This is free software distributed under the terms of the MIT license
Generator code uses code from the Confide package. It is then modified to fit this application. Thanks goes out to @Zizaco for that code.
Workbench tutorial by Jason Lewis was excellent in getting up and running with workbench.
Image upload tutorial from Phil Sturgeon which inspired me to create this package.
Any questions, feel free to contact me.