{"id":36399184,"url":"https://github.com/yoshkin/laravel-imagetrait","last_synced_at":"2026-01-11T16:01:46.630Z","repository":{"id":57086222,"uuid":"108951021","full_name":"yoshkin/laravel-imagetrait","owner":"yoshkin","description":"hacktoberfest 2017","archived":false,"fork":false,"pushed_at":"2018-10-08T02:27:56.000Z","size":33,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-05-02T19:47:45.895Z","etag":null,"topics":["hacktober","hacktoberfest","hacktoberfest2017"],"latest_commit_sha":null,"homepage":null,"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/yoshkin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-31T05:47:49.000Z","updated_at":"2020-02-11T05:57:12.000Z","dependencies_parsed_at":"2022-08-24T14:59:12.256Z","dependency_job_id":null,"html_url":"https://github.com/yoshkin/laravel-imagetrait","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yoshkin/laravel-imagetrait","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshkin%2Flaravel-imagetrait","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshkin%2Flaravel-imagetrait/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshkin%2Flaravel-imagetrait/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshkin%2Flaravel-imagetrait/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yoshkin","download_url":"https://codeload.github.com/yoshkin/laravel-imagetrait/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yoshkin%2Flaravel-imagetrait/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28312136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-11T14:58:17.114Z","status":"ssl_error","status_checked_at":"2026-01-11T14:55:53.580Z","response_time":60,"last_error":"SSL_read: 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":["hacktober","hacktoberfest","hacktoberfest2017"],"created_at":"2026-01-11T16:01:33.186Z","updated_at":"2026-01-11T16:01:46.609Z","avatar_url":"https://github.com/yoshkin.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel ImageTrait\n\u003e for Hacktoberfest 2017\n\nImageTrait for Laravel 5.4\n\n## Requirements\n* laravel 5.4^\n(Because trait uses Storage and Image class of laravel package)\n\n## Features\nHandle image file upload and DB storage for a image file:\n- on CREATE:\n* stores the image file at the destination path\n* generates a name\n* stores the path in the DB;\n\n- on UPDATE:\n* if the value is null, deletes the image file and sets null in the DB\n* if the value is different, stores the different image file and updates DB value.\n\n## Installing #1\n```\ncomposer require yashenkov/laravel-imagetrait\n```\n## Installing #2\n```\nDownload ImageTrait.php, than place it in app/Traits. \nReplace namespase \"Yashenkov\\ImageTrait\\Traits\" by \"App\\Traits\"\n```\n\n#### Using:\nIn your model, that have image attribute you need to \nadd in Model use ImageTrait, for example:\n```php\n\u003c?php\nnamespace App\\Models;\n\nuse App\\Traits\\ImageTrait;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Product extends Model {\n    use ImageTrait;\n    ...\n}\n```\n\nThen you can use method of the trait in Model class as mutator of image attribute:\n```php\n\u003c?php\nnamespace App\\Models;\n\nuse App\\Traits\\ImageTrait;\nuse Illuminate\\Database\\Eloquent\\Model;\n\nclass Product extends Model {\n    use ImageTrait;\n    \n    public $disk = \"uploads\";\n    public $destination_path = \"products\";\n    public $imageWidth = 270;\n    public $imageHeight = 270;\n        \n    /**\n    * Mutators\n    */\n    \n    public function setImageAttribute($value, $attribute_name = 'image')\n    {\n        $this-\u003euploadImageToDisk($value, $attribute_name, $this-\u003edisk, $this-\u003edestination_path, $this-\u003eimageWidth, $this-\u003eimageHeight);\n    }\n}\n```\n\n##Licence\nMIT\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoshkin%2Flaravel-imagetrait","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyoshkin%2Flaravel-imagetrait","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyoshkin%2Flaravel-imagetrait/lists"}