{"id":18729797,"url":"https://github.com/laravelir/attachmentable","last_synced_at":"2025-04-12T16:53:20.435Z","repository":{"id":57012206,"uuid":"399278910","full_name":"laravelir/attachmentable","owner":"laravelir","description":"A package for attachment files to models","archived":false,"fork":false,"pushed_at":"2023-10-21T15:44:57.000Z","size":59,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-23T16:46:31.072Z","etag":null,"topics":["eloquent","filesystem","laravel","laravel-attachmentable","laravel-model","laravel-package","laravel-uploader","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/laravelir.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://idpay.ir/laravelir"]}},"created_at":"2021-08-23T23:51:21.000Z","updated_at":"2022-01-18T18:03:37.000Z","dependencies_parsed_at":"2022-08-21T13:40:48.777Z","dependency_job_id":"e8240206-a50e-498f-968e-c561d0f2257d","html_url":"https://github.com/laravelir/attachmentable","commit_stats":{"total_commits":15,"total_committers":2,"mean_commits":7.5,"dds":0.06666666666666665,"last_synced_commit":"92d3d20f7d5eb9dce426a0867cb020457721a68c"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":"miladimos/package-skeleton","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravelir%2Fattachmentable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravelir%2Fattachmentable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravelir%2Fattachmentable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravelir%2Fattachmentable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laravelir","download_url":"https://codeload.github.com/laravelir/attachmentable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248601360,"owners_count":21131609,"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":["eloquent","filesystem","laravel","laravel-attachmentable","laravel-model","laravel-package","laravel-uploader","php"],"created_at":"2024-11-07T14:28:50.763Z","updated_at":"2025-04-12T16:53:20.413Z","avatar_url":"https://github.com/laravelir.png","language":"PHP","readme":"- [![Starts](https://img.shields.io/github/stars/laravelir/attachmentable?style=flat\u0026logo=github)](https://github.com/laravelir/attachmentable/forks)\n- [![Forks](https://img.shields.io/github/forks/laravelir/attachmentable?style=flat\u0026logo=github)](https://github.com/laravelir/attachmentable/stargazers)\n\n# Laravel attachmentable package\n\nA package for attachment files to models\n\n## Installation\n\n1. Run the command below to add this package:\n\n```\ncomposer require laravelir/attachmentable\n```\n\n2. Open your config/attachmentable.php and add the following to the providers array:\n\n```php\nLaravelir\\Attachmentable\\Providers\\AttachmentableServiceProvider::class,\n```\n\n3. Run the command below to install package:\n\n```\nphp artisan attachmentable:install\n```\n\n4. Run the command below to migrate database:\n\n```\nphp artisan migrate\n```\n\n## Uses\n\nFirst add `Attachmentable` trait to models that you want have attachments\n\n```php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Laravelir\\Attachmentable\\Traits\\Attachmentable;\n\nclass Post extends Model\n{\n    use HasFactory,\n        Attachmentable;\n}\n\n```\n\n\nand add `Attachmentorable` trait to User models\n\n```php\n\nnamespace App\\Models;\n\nuse Illuminate\\Database\\Eloquent\\Factories\\HasFactory;\nuse Illuminate\\Database\\Eloquent\\Model;\nuse Laravelir\\Attachmentable\\Traits\\Attachmentorable;\n\nclass User extends Model\n{\n    use HasFactory,\n        Attachmentorable;\n}\n\n```\n\n### Methods\n\nin controllers, with `Attachmentable` trait you have these methods:\n\n```php\n\nnamespace App\\Http\\Controllers;\n\nuse App\\Models\\Post;\n\nclass PostController extends Controller\n{\n    public function index()\n    {\n        $file = request()-\u003efile('thumbnail');\n        \n        $post = Post::find(1);\n\n        $post-\u003eattach($file, \"posts/thumbnails\");\n\n        $post-\u003eattachments // return all attachments\n\n        $post-\u003eattachment($id); // return attachment \n               \n        $post-\u003edetach($id);\n        \n        $post-\u003eclearAttachments();\n       \n    }\n}\n\n```\n","funding_links":["https://idpay.ir/laravelir"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaravelir%2Fattachmentable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaravelir%2Fattachmentable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaravelir%2Fattachmentable/lists"}