Skip to content
This repository was archived by the owner on Feb 3, 2023. It is now read-only.

Commit c6660d7

Browse files
committed
Autoloading and license
1 parent 5f0051f commit c6660d7

File tree

5 files changed

+64
-22
lines changed

5 files changed

+64
-22
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 Ivan Radunovic <[email protected]>
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

composer.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1-
21
{
32
"name": "codingo-me/dropzoner",
43
"description": "Simpe Laravel package for image uploads using DropzoneJS library",
4+
"keywords":["laravel", "dropzone"],
5+
"license":"MIT",
6+
"authors": [
7+
{
8+
"name": "Ivan Radunovic",
9+
"email": "[email protected]"
10+
}
11+
],
512
"require": {
13+
"php": ">=5.4.0",
614
"intervention/image": "^2.3"
15+
},
16+
"autoload":{
17+
"psr-4": {
18+
"Codingo\\Dropzoner\\": "src/"
19+
}
720
}
821
}

readme.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# Dropzoner - Laravel package for image upload using DropzoneJS
22

3+
[![Software License][ico-license]](LICENSE.md)
4+
35
This is the simplest Laravel package for image uploads using DropzoneJS.
46

5-
You pull it via composer, set service provider and include it in your views with **@include('dropzoner')** and set JS and CSS files in header and footer.
6-
It will take full width of parent container, and will throw events on image upload and image delete actions.
7+
You pull it via composer, set service provider and include it in your views with **@include('dropzoner')**. After this you need to set JS and CSS files in header and footer.
8+
Dropzone will take full width of parent container, and will throw events on image upload and image delete actions.
79
Using event listeners you can hook this package with the rest of your application.
810

911
Package uses Image Intervention library for saving images. It has its own filename sanitizer and method for creating unique filenames inside upload directory.
@@ -12,25 +14,25 @@ Package uses Image Intervention library for saving images. It has its own filena
1214

1315
Require package in your Laravel project with:
1416

17+
```shell
18+
composer require codingo-me/dropzoner
19+
```
1520

16-
Or add it into composer.json:
17-
18-
19-
..and run
21+
Now modify app.php config file and add Dropzoner Service Provider.
2022

21-
```shell
22-
composer update
23+
```php
24+
Codingo\Dropzoner\DropzonerServiceProvider::class
2325
```
2426

25-
After installation you need to publish Dropzoners config and assets:
27+
After setting service provider you need to publish Dropzoners configuration file and assets:
2628

2729
```shell
2830
php artisan vendor:publish
2931
```
3032

3133
When you publish these files, you will be able to modify Dropzoner configuration. There you'll find validator array and validator-messages array.
3234

33-
You also need to add upload path into .env file using key **DROPZONER_UPLOAD_PATH**. This directory should be write-able by web server.
35+
You also need to add upload path into .env file using key **DROPZONER_UPLOAD_PATH**. This directory should be write-able by web server, and it needs to end with trailing slash.
3436

3537
### Namespace
3638

@@ -104,4 +106,9 @@ class ImageUploadListener
104106
}
105107
```
106108

107-
If you have some ideas for features, just open issues here on GitHub or send me an email.
109+
## License
110+
111+
MIT License (MIT). See [License File](https://github.com/codingo-me/dropzoner/blob/master/LICENSE) for more information.
112+
113+
114+
[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square

src/Http/Controllers/DropzonerController.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Codingo\Dropzoner\Http\Controllers;
44

5+
use Illuminate\Http\Request;
56
use Illuminate\Routing\Controller;
67
use Codingo\Dropzoner\Repositories\UploadRepository;
78

@@ -24,16 +25,16 @@ public function __construct(UploadRepository $uploadRepository)
2425
*
2526
* @return mixed
2627
*/
27-
public function postUpload()
28+
public function postUpload(Request $request)
2829
{
29-
$input = \Input::all();
30+
$input = $request->all();
3031
$response = $this->uploadRepository->upload($input);
3132
return $response;
3233
}
3334

34-
public function postDelete()
35+
public function postDelete(Request $request)
3536
{
36-
$response = $this->uploadRepository->delete(\Input::get('id'));
37+
$response = $this->uploadRepository->delete($request->input('id'));
3738
return $response;
3839
}
3940

src/repositories/UploadRepository.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function upload($input)
2020

2121
if ($validator->fails()) {
2222

23-
return \Response::json([
23+
return response()->json([
2424
'error' => true,
2525
'message' => $validator->messages()->first(),
2626
'code' => 400
@@ -43,7 +43,7 @@ public function upload($input)
4343

4444
if( !$image ) {
4545

46-
return \Response::json([
46+
return response()->json([
4747
'error' => true,
4848
'message' => 'Server error while uploading',
4949
'code' => 500
@@ -54,7 +54,7 @@ public function upload($input)
5454
//Fire ImageWasUploaded Event
5555
event(new ImageWasUploaded($original_name, $filename_with_extension));
5656

57-
return \Response::json([
57+
return response()->json([
5858
'error' => false,
5959
'code' => 200,
6060
'filename' => $filename_with_extension
@@ -64,13 +64,13 @@ public function upload($input)
6464
/**
6565
* Delete Single Image
6666
*
67+
* @param $server_filename
6768
* @return mixed
6869
*/
69-
public function delete()
70+
public function delete($server_filename)
7071
{
7172
$upload_path = config('dropzoner.upload-path');
7273

73-
$server_filename = \Input::get('id');
7474
$full_path = $upload_path . $server_filename;
7575

7676
if (\File::exists($full_path)) {
@@ -79,7 +79,7 @@ public function delete()
7979

8080
event(new ImageWasDeleted($server_filename));
8181

82-
return \Response::json([
82+
return response()->json([
8383
'error' => false,
8484
'code' => 200
8585
], 200);

0 commit comments

Comments
 (0)