{"id":22889600,"url":"https://github.com/dillingham/interacts-with-uploads","last_synced_at":"2026-03-19T23:54:53.422Z","repository":{"id":56969081,"uuid":"358403061","full_name":"dillingham/interacts-with-uploads","owner":"dillingham","description":"Adds upload method to requests","archived":false,"fork":false,"pushed_at":"2021-04-15T21:59:44.000Z","size":189,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-31T21:03:08.065Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","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/dillingham.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":"2021-04-15T21:58:29.000Z","updated_at":"2022-04-01T21:54:18.000Z","dependencies_parsed_at":"2022-08-21T06:40:14.509Z","dependency_job_id":null,"html_url":"https://github.com/dillingham/interacts-with-uploads","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dillingham/interacts-with-uploads","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Finteracts-with-uploads","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Finteracts-with-uploads/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Finteracts-with-uploads/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Finteracts-with-uploads/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dillingham","download_url":"https://codeload.github.com/dillingham/interacts-with-uploads/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dillingham%2Finteracts-with-uploads/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29208161,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T20:13:33.422Z","status":"ssl_error","status_checked_at":"2026-02-07T20:13:31.455Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-12-13T21:56:20.217Z","updated_at":"2026-02-07T20:31:10.225Z","avatar_url":"https://github.com/dillingham.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"## InteractsWithUploads\n\nLaravel trait adds FormRequest upload\n\n\u003cp\u003e\n    \u003ca href=\"https://github.com/dillingham/interacts-with-uploads/actions\"\u003e\n        \u003cimg src=\"https://github.com/dillingham/interacts-with-uploads/workflows/tests/badge.svg\" alt=\"Build Status\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/dillingham/interacts-with-uploads\"\u003e\n        \u003cimg src=\"https://img.shields.io/packagist/v/dillingham/interacts-with-uploads\" alt=\"Latest Stable Version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/dillingham/interacts-with-uploads\"\u003e\n        \u003cimg src=\"https://img.shields.io/packagist/dt/dillingham/interacts-with-uploads\" alt=\"Total Downloads\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://twitter.com/im_brian_d\"\u003e\n        \u003cimg src=\"https://img.shields.io/twitter/follow/im_brian_d?color=%231da1f1\u0026label=Twitter\u0026logo=%231da1f1\u0026logoColor=%231da1f1\u0026style=flat-square\" alt=\"twitter\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n\n## Install\n```\ncomposer require dillingham/interacts-with-uploads\n```\n\nAnd add the following trait to your FormRequest classes\n\n```php\nuse \\Dillingham\\InteractsWithUploads;\n``` \n\nNow you can call the following methods in controllers:\n\n---\n\n### New uploads \n\n```\n$request-\u003eupload('key')\n```\n\n```php\npublic function store(CreateProfileRequest $request) \n{\n    $request-\u003eupload('banner');\n\n    $profile = Profile::create($request-\u003evalidated());\n\n    return redirect()-\u003eroute('profiles.show', $profile);\n}\n```\nStore the file and add it's path to `validated()` for the same key: `banner`\n\nThis makes `$profile-\u003ebanner` equal to `/uploads/asfos8asfoafaf9q3wf.jpg`\n\n---\n\n### Update uploads\n\n```\n$request-\u003eupload('binding.key')\n```\n \n```php\npublic function update(UpdateProfileRequest $request, Profile $profile)\n{\n    $request-\u003eupload('profile.banner');\n\n    $profile-\u003eupdate($request-\u003evalidated());\n\n    return redirect()-\u003eroute('profiles.show', $profile);\n}\n```\nIf the request has a new file for `key`, it deletes the old and uploads the new\n\nIf no new file is in the request, it will add the original file path back to `validated()`\n\nSo submitting `null` for that `key` will result in the same path / no changes to the model.\n\nIt will get the original file path using the `key` \u0026 [route model binding](https://laravel.com/docs/routing#route-model-binding), in this scenario.. `profile`\n\nThe binding `profile` connects a typehinted model \u0026 defined in `Route::`  using `{binding}` syntax\n\n---\n\n### Manual update \n\nIf you are not using route model binding, you can manually set the path to update.\n\n```php\npublic function update(UpdateProfileRequest $request, Profile $profile)\n{\n    $request-\u003eupdateUpload($profile, 'banner');\n\n    $profile-\u003eupdate($request-\u003evalidated());\n\n    return redirect()-\u003eroute('profiles.show', $profile);\n}\n```\n\n## Parameters\n\nYou can specify a few options and override the defaults.\n```php\n$request-\u003eupload('banner', 'uploads', 'public');\n```\n- `uploads`: is the default path within storage \n- `public`: is the default disk within config/filesystems\n\n### Author\n\n[@im_brian_d](https://twitter.com/im_brian_d) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdillingham%2Finteracts-with-uploads","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdillingham%2Finteracts-with-uploads","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdillingham%2Finteracts-with-uploads/lists"}