{"id":21525834,"url":"https://github.com/bkwld/upchuck","last_synced_at":"2026-03-07T13:31:29.264Z","repository":{"id":29610740,"uuid":"33151116","full_name":"BKWLD/upchuck","owner":"BKWLD","description":"A simple, automatic handler of file uploads for Laravel's Eloquent models using using Flysystem.","archived":false,"fork":false,"pushed_at":"2022-01-19T00:38:26.000Z","size":61,"stargazers_count":22,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T01:12:35.875Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/BKWLD.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":"2015-03-30T22:12:08.000Z","updated_at":"2023-01-25T10:21:43.000Z","dependencies_parsed_at":"2022-08-17T19:55:21.171Z","dependency_job_id":null,"html_url":"https://github.com/BKWLD/upchuck","commit_stats":null,"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BKWLD%2Fupchuck","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BKWLD%2Fupchuck/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BKWLD%2Fupchuck/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BKWLD%2Fupchuck/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BKWLD","download_url":"https://codeload.github.com/BKWLD/upchuck/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248126807,"owners_count":21052043,"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-24T01:38:38.762Z","updated_at":"2026-03-07T13:31:29.206Z","avatar_url":"https://github.com/BKWLD.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Upchuck\n\n[![Packagist](https://img.shields.io/packagist/v/bkwld/upchuck.svg)](https://packagist.org/packages/bkwld/upchuck)\n\nUpchuck is a simple, automatic handler of file uploads for [Laravel's](http://laravel.com/) [Eloquent](http://laravel.com/docs/eloquent) models using using [Flysystem](http://flysystem.thephpleague.com/).  It does not attempt to do anything besides let the developer treat file uploads like regular input fields.  It does this by listening to Eloquent `saving` events,  checking the model attribute for `UploadedFile` instances, pushing those files to \"disk\" of your choosing, and then storing the publically accessible URL in the model attribute for that input.\n\n\n## Installation\n\n1. Add to your project: `composer require bkwld/upchuck:~2.0`\n2. *Laravel \u003c 5.5 only* Add Upchuck as a provider in your app/config/app.php's provider list: `'Bkwld\\Upchuck\\ServiceProvider',`\n3. Publish the config: `php artisan vendor:publish --provider=\"Bkwld\\Upchuck\\ServiceProvider\"`\n\n\n## Usage\n\nEdit the `disk` config setting to supply configuration information for where uploads should be moved.  We are using [Graham Campbell's Flysystem](https://github.com/GrahamCampbell/Laravel-Flysystem) integration for Laravel to instantiate Flysystem instances, so the configruation of the `disk` matches his [configuration options for connections](https://github.com/GrahamCampbell/Laravel-Flysystem/blob/1.0/src/config/config.php#L38).  As the comments in the config file mention, I recommend turning on caching if you are using any disk other than `local`.  For both [caching](https://github.com/thephpleague/flysystem-cached-adapter) and [other disk drivers](https://github.com/thephpleague/flysystem#adapters), you will need to include other packages.\n\nThen, to enable upload support for your models, use the `Bkwld\\Upchuck\\SupportsUploads` trait on your model and itemize each attribute that should support uploads via the `$upload_attributes` property.  For example:\n\n```php\nclass Person extends Eloquent {\n\n\t// Use the trait\n\tuse Bkwld\\Upchuck\\SupportsUploads;\n\n\t// Define the uploadable attributes\n\tprotected $upload_attributes = [ 'image', 'pdf', ];\n\n\t// Since the upload handling happens via model events, it acts like a mass\n\t// assignment.  As such, Upchuck sets attributes via `fill()` so you can\n\t// control the setting.\n\tprotected $fillable = ['image', 'pdf'];\n}\n```\n\nThen, say you have a `\u003cinput type=\"file\" name=\"image\"\u003e` field, you would do this from your controller:\n\n```php\n$model = new Model;\n$model-\u003efill(Input::all())\n$model-\u003esave();\n```\n\nYou are filling the object with the `Input:all()` array, which includes your image data as an `UploadedFile` object keyed to the `image` attribute.  When you `save()`, Upchuck will act on the `saving` event, moving the upload into the storage you've defined in the config file, and replacing the attribute value with the URL of the file.\n\n\n### Resizing images\n\nIf your app supports uploading files you are probably also dealing with needing to resize uploaded images.  We (BKWLD) use our [Croppa](https://github.com/BKWLD/croppa) package to resize images using specially formatted URLs.  If you are looking for an model-upload package that also resizes images, you might want to check out [Stapler](https://github.com/CodeSleeve/stapler).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkwld%2Fupchuck","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbkwld%2Fupchuck","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbkwld%2Fupchuck/lists"}