juice / attachments
Juice Attachments Plugin.
Requires
- php: ^7.2
- hashids/hashids: ~3.0|~4.0
- illuminate/cache: ~5.7|~6.0|~7.0|~8.0
- illuminate/console: ~5.7|~6.0|~7.0|~8.0
- illuminate/database: ~5.7|~6.0|~7.0|~8.0
- illuminate/filesystem: ~5.7|~6.0|~7.0|~8.0
- illuminate/support: ~5.7|~6.0|~7.0|~8.0
- intervention/image: ~2.4
- ralouphie/mimey: ~2.0
Requires (Dev)
- ext-json: *
- mockery/mockery: ~1.2
- orchestra/testbench: ~3.7|~4.0|~5.0
- phpunit/phpunit: ~7.4|~8.0|~9.0
This package is auto-updated.
Last update: 2024-10-27 14:55:15 UTC
README
Provide attachment controller and just use it in your application routes. We take care rest of things.
Installation
-
run composer require command
composer require juice/attachments
-
register
\Juice\Attachments\AttachmentsServiceProvider::class
service provider -
copy config file and set it up
-
Laravel -
php artisan vendor:publish --provider="Juice\Attachments\AttachmentsServiceProvider"
-
Lumen -
cp vendor/juice/attachments/config/juice-attachments.php config/
(make sure config directory exist)
-
-
run setup command
php artisan attachment:setup
-
run database migration
php artisan migrate
-
setup your application routes
-
done
Controller Methods
*:Assume route namespace is \Juice\Attachments\Controllers
Upload Attachments
-
end point
AttachmentController@upload
-
method parameters
none
-
query string
none
-
form data
-
return value
array of successfully uploaded files' name, e.g.
["sjdwd.png", "pweog.pdf", "msptw.jpeg"]
-
route example
Route::post('/attachments', 'AttachmentController@upload');
Download Attachment
-
end point
AttachmentController@download
-
method parameters
-
query string
-
form data
none
-
return value
Symfony\Component\HttpFoundation\BinaryFileResponse
-
route example
Route::get('/attachments/{id}', 'AttachmentController@download'); // https://example.com/attachments/sjdwd.png
Trash Attachment
-
end point
AttachmentController@trash
-
method parameters
-
query string
none
-
form data
none
-
return value
json response contain success key, e.g.
{ "success": true }
-
route example
Route::delete('/attachments/{id}', 'AttachmentController@trash'); // https://example.com/attachments/sjdwd.png