Skip to content

Commit

Permalink
Merge pull request #24 from mhor/patch-1
Browse files Browse the repository at this point in the history
Highlighting
  • Loading branch information
andrewelkins committed Dec 22, 2014
2 parents 359de78 + f531031 commit e96f184
Showing 1 changed file with 62 additions and 36 deletions.
98 changes: 62 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,62 +23,77 @@ In the `require` key of `composer.json` file add the following:

For use with Laravel 4.1.x

"andrewelkins/cabinet": "1.0.x"
```json
"andrewelkins/cabinet": "1.0.x"
```

For use with Laravel 4.2.x

"andrewelkins/cabinet": "1.1.x"
```json
"andrewelkins/cabinet": "1.1.x"
```

Run the Composer update command

$ composer update
```bash
$ composer update
```

In your `config/app.php` add `'Andrew13\Cabinet\CabinetServiceProvider'` to the end of the `$providers` array

'providers' => array(
```php
'providers' => array(

'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
...
'Andrew13\Cabinet\CabinetServiceProvider',
'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',
```php
'aliases' => array(

),
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
...
'Cabinet' => 'Andrew13\Cabinet\CabinetFacade',

),
```

### Upload model

Now generate the Cabinet migration:

$ php artisan cabinet:migration
```bash
$ 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
```bash
$ 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
```php
<?php

use Andrew13\Cabinet\CabinetUpload;
use Andrew13\Cabinet\CabinetUpload;

class Upload extends CabinetUpload {
class Upload extends CabinetUpload {

protected $softDelete = true;
protected $softDelete = true;

}
}
```

`CabinetUpload` class will take care of all the default upload behavior. This can be extended in your Upload model.

Expand All @@ -87,20 +102,23 @@ Create an upload model in `app/models/Upload.php`:

Least, you can dump a default controller and the default routes for Cabinet.

$ php artisan cabinet:controller
$ php artisan cabinet:routes
```bash
$ php artisan cabinet:controller
$ php artisan cabinet:routes
```

Don't forget to dump composer autoload

$ composer dump-autoload

```bash
$ composer dump-autoload
```

### Publish public assets

In order to use the js/css/images you'll need to publish the assets.

```
php artisan asset:publish andrew13/cabinet
```bash
$ php artisan asset:publish andrew13/cabinet
```

**And you are ready to go.**
Expand All @@ -113,21 +131,26 @@ Access `http://localhost/upload` to upload a file. It is highly suggested to put

To change the controller name when dumping the default controller template you can use the --name option.

$ php artisan cabinet:controller --name Uploader
```bash
$ 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

```bash
$ php artisan confide:routes --controller Uploader
```

<a name="config"></a>
#### Using custom form for upload and other configuration options.

First, publish the config files:

$ php artisan config:publish andrew13/cabinet
```bash
$ php artisan config:publish andrew13/cabinet
```

Then edit the view names in `app/config/packages/andrew13/confide/config.php`.

Expand All @@ -137,14 +160,17 @@ Further, you can change the location of the uploads, type of upload files, and m

If you want to generate a [RESTful controller](https://github.com/laravel/docs/blob/master/controllers.md#restful-controllers) you can use the additional `--restful` or `-r` option.

$ php artisan cabinet:controller --restful
```bash
$ php artisan cabinet:controller --restful
```

Will result in a [RESTful controller](https://github.com/laravel/docs/blob/master/controllers.md#restful-controllers)

Then, when dumping the routes, you should use the --restful option to match the existing controller.

$ php artisan cabinet:routes --restful

```bash
$ php artisan cabinet:routes --restful
```

-----
## License
Expand Down

0 comments on commit e96f184

Please sign in to comment.