{"id":19706762,"url":"https://github.com/unisharp/laravel-uploadable","last_synced_at":"2025-04-29T16:33:41.707Z","repository":{"id":57075578,"uuid":"113154905","full_name":"UniSharp/laravel-uploadable","owner":"UniSharp","description":null,"archived":false,"fork":false,"pushed_at":"2018-11-19T06:00:57.000Z","size":53,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-04-05T18:12:28.377Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/UniSharp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-05T08:33:21.000Z","updated_at":"2018-11-19T06:00:58.000Z","dependencies_parsed_at":"2022-08-24T14:55:44.623Z","dependency_job_id":null,"html_url":"https://github.com/UniSharp/laravel-uploadable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Flaravel-uploadable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Flaravel-uploadable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Flaravel-uploadable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Flaravel-uploadable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UniSharp","download_url":"https://codeload.github.com/UniSharp/laravel-uploadable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251540550,"owners_count":21605929,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T21:36:56.270Z","updated_at":"2025-04-29T16:33:36.694Z","avatar_url":"https://github.com/UniSharp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Uploadable\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nA simple package to attach files to a eloquent model.\n\n## Installation\n\n```\ncomposer require unisharp/laravel-uploadable dev-master\n```\n\n## Configuration\n\nSet configuration in `config/uploadable.php`\n\n```php\nreturn [\n    // Set image orientate enable or disable\n    'use_image_orientate' =\u003e false,\n\n    // Set thumbnail size\n    'thumbs' =\u003e [\n        's' =\u003e '96x96',\n        'm' =\u003e '256x256',\n        'l' =\u003e '480x480'\n    ],\n\n    // Set image handler\n    'plugins' =\u003e [\n        ImageHandler::class\n    ]\n];\n```\n\n## Usages\n\n### Use trait in the model\n\n```php\n\nnamespace App;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Unisharp\\Uploadable\\CanUpload;\n\nclass Product extends Model\n{\n    use CanUpload;\n    \n    public function image()\n    {\n        return $this-\u003emorphOne(Image::class, 'imageable');\n    }\n}\n```\n\n### Manually upload and Delete files\n\n```php\n// Upload a file\n$product = new Product();\n$product-\u003eupload(request()-\u003efile());\n\n// Delete a file\n$file = $product-\u003efiles()-\u003efirst();\n$product-\u003eremoveFiles($file-\u003eid);\n\n// Delete files\n$files = $product-\u003efiles-\u003epluck('id');\n$product-\u003eremoveFiles($files);\n```\n\n### Upload/Delete through APIs\n\n```php\n\n// POST /files/ \u0026 DELETE /files/{file}\nUniSharp\\Uploadable\\UploaderManager::route();\n\n// POST /files/\nUniSharp\\Uploadable\\UploaderManager::route(['store']);\n\n// POST /files/ with callback\nUniSharp\\Uploadable\\UploaderManager::route(['store'], function () {\n    ...\n});\n\n```\n\n### Customize image handler\n\nImage Handler\n\n```php\nuse Intervention\\Image\\Facades\\Image;\nuse Illuminate\\Filesystem\\FilesystemAdapter;\n\nclass CustomImageHandler {\n    public function handle(FilesystemAdapter $storage, $path)\n    {\n        $image = Image::make($storage-\u003epath($path));\n    \n        ...\n    \n        $image-\u003esave();\n    }\n}\n```\n\nSet Custom image handler in `config/uploadable.php`\n\n```php\nreturn [\n    'plugins' =\u003e [\n        CustomImageHandler::class\n    ]\n];\n```\n\n[ico-version]: https://img.shields.io/packagist/v/UniSharp/laravel-uploadable.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/UniSharp/laravel-uploadable/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/UniSharp/laravel-uploadable.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/UniSharp/laravel-uploadable.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/UniSharp/laravel-uploadable.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/unisharp/laravel-uploadable\n[link-travis]: https://travis-ci.org/UniSharp/laravel-uploadable\n[link-scrutinizer]: https://scrutinizer-ci.com/g/UniSharp/laravel-uploadable/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/UniSharp/laravel-uploadable\n[link-downloads]: https://packagist.org/packages/UniSharp/laravel-uploadable\n[link-author]: https://github.com/Nehemis1615\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funisharp%2Flaravel-uploadable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funisharp%2Flaravel-uploadable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funisharp%2Flaravel-uploadable/lists"}