{"id":16462186,"url":"https://github.com/digitaldreams/photo","last_synced_at":"2025-07-29T12:08:48.964Z","repository":{"id":34898738,"uuid":"188075423","full_name":"digitaldreams/photo","owner":"digitaldreams","description":"Laravel Photo Manager","archived":false,"fork":false,"pushed_at":"2024-04-14T08:34:41.000Z","size":1884,"stargazers_count":33,"open_issues_count":12,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-07T12:47:09.179Z","etag":null,"topics":["gallery","image-processing","intervention-image","laravel-5-package","laravel-package","photo-gallery"],"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/digitaldreams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2019-05-22T16:25:57.000Z","updated_at":"2024-07-18T12:21:29.000Z","dependencies_parsed_at":"2024-10-11T11:10:54.483Z","dependency_job_id":"1dbedf7b-4400-4b3a-b1cc-80836b5bec53","html_url":"https://github.com/digitaldreams/photo","commit_stats":{"total_commits":110,"total_committers":2,"mean_commits":55.0,"dds":"0.027272727272727226","last_synced_commit":"547ab29d81bec00c06d64899764edf6356e48d52"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldreams%2Fphoto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldreams%2Fphoto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldreams%2Fphoto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldreams%2Fphoto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitaldreams","download_url":"https://codeload.github.com/digitaldreams/photo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826788,"owners_count":20354220,"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":["gallery","image-processing","intervention-image","laravel-5-package","laravel-package","photo-gallery"],"created_at":"2024-10-11T11:10:38.546Z","updated_at":"2025-03-16T18:31:24.269Z","avatar_url":"https://github.com/digitaldreams.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravl Photo Manager \nLaravel Photo Manager\n### Installation\n**Step one**\n```php\n composer require digitaldream/photo\n```\n**Step Two**\nRun Migration\n```php\n php artisan migrate\n```\n**Step Three**\n```php\n php artisan vendor:publish --provider=\"Photo/PhotoServiceProvider\"\n```\n\nIt will publish config, views file. Feel free to edit these files according to your project need.\n\n**Step Four**\n\nBrowse **/photo/photos** to start using this library\n\n### Configure Policy\nYou can configure who can have what permissions on this photo library.\n Create a new class and extends it from `Photo\\Policies\\PhotoPolicy` like below.\n ```php\n  namespace App\\Policies;\n  \n  use Photo\\Policies\\PhotoPolicy as Policy;\n\n   class PhotoPolicy extends Policy\n   {\n       /**\n        * @param \\App\\Models\\User $user\n        *\n        * @return bool\n        */\n       public function viewAny($user): bool\n       {\n           return $user-\u003eisTeacher();\n       }\n   }\n```\nAs you can see we override viewAny method. Now a Teacher can view list of all photos.\nOther methods like `before`,`view`,`create`,`update`,`delete` can be override too.\nNow to register this Policy class lets change `policy` key on  `config/photo.php`\n\n    #file config/photo.php\n    \n    'policy' =\u003e \\App\\Policies\\PhotoPolicy::class,\n\n### Features\n1.Drag and Drop from Web.\n\n2.Drag and Drop from Local machine\n\n3.Crop and Resize\n\n4.Webp conversion\n\n5.Copy image URL and share to the Web\n\n7.Size configurable and thumbnails generation\n\n8.SEO friendly filename. \n\n9.Translation\n\n10.PHPunit test classes included. \n\u003cimg src=\"https://i.ibb.co/y47HP3g/Screenshot-2020-11-07-at-11-19-13-PM.png\" alt=\"Drag n Drop from local machine\" border=\"0\"\u003e\n\u003cimg src=\"https://i.ibb.co/2tT1W40/Resize-image.png\" alt=\"Resize-image\" border=\"0\"\u003e\n\n### How to use in a Model as BelongsTo\nFirst of all you need to put a line on your model migration for example posts.\n```php\n$table-\u003eforeign('photo_id')-\u003ereferences('id')-\u003eon('photo_photos')-\u003eonDelete('set null');\n```\nSecondly you need to define relation on your model. \n\n```php\n    /**\n     * @return \\Illuminate\\Database\\Eloquent\\Relations\\BelongsTo\n     */\n    public function photo()\n    {\n        return $this-\u003ebelongsTo(\\Photo\\Models\\Photo::class, 'photo_id');\n    }\n```\nThird. Lets make upload on controller. \n```php\n    /**\n    * @var \\Photo\\Repositories\\PhotoRepository\n    */\n    protected $photoRepository;\n            \n    public function __construct(PhotoRepository $photoRepository)\n    {\n        $this-\u003ephotoRepository = $photoRepository;\n    }\n    \n    public function store(StoreRequest $request)\n    {\n    //Your other code.\n        $post-\u003ephoto_id = $this-\u003ephotoRepository-\u003ecreate($file, ['caption' =\u003e $data['title']])-\u003eid;\n    }\n```\nYou must resolve `\\Photo\\Repositories\\PhotoRepository` via `__construction` Dependency injection.\n\nFinally. Its time to render image to view. \n\n```blade\n {!! $post-\u003ephoto-\u003erenderThumbnails() !!}\n```\nThis will render following html code. \n```html\n\u003cpicture\u003e\n    \u003csource type=\"image/webp\" srcset=\"https://YourSite.com/storage/posts/thumbnails/nice-quietly-their-belong-place-on-it-the-appeared-to.webp\"\u003e\n    \u003cimg src=\"https://YourSite.com/storage/posts/thumbnails/nice-quietly-their-belong-place-on-it-the-appeared-to.jpeg\" alt=\"Nice, quietly their belong, place on. It the appeared to\"\u003e\n\u003c/picture\u003e\n```\nAbove code will render thumbnails in both webp and uploaded extension. \nTo render larger image do following\n```blade\n    {!! $post-\u003ephoto-\u003erender('card-img-top') !!}\n```\nHere render method take class name as first argument and style as second.\n\n### How to upload file and get file path only.\n\n```php\n    namesapce App\\Repositories;\n    \n    class PostRepository\n    {\n       /**\n        * @var \\Photo\\Services\\PhotoService\n        */\n        protected PhotoService $photoService;\n        \n        public function __construct(PhotoService $photoService)\n        {\n            $this-\u003ephotoService = $photoService;\n        }\n        \n        public function store(Request $request)\n        {\n            $post = new Post();\n            $post-\u003efill($request-\u003eall());\n            \n            $mainImageFolder = \"posts\"\n            $thumbnailWidth = 220;\n            $thumbnailHheight= 200;\n            $crop=\"no\"; // \"yes\" will resize image automatically based on your maximum height,width.\n            $thumbnailPath = \"thumbnails\"; // Thumbnails path are relative to main Image folder. \n                                            //In this case it will create a folder thumbnails under posts folder.\n                        \n            $post-\u003eimage =  $this-\u003ephotoService\n                                    -\u003esetDimension($thumbnailWidth, $thumbnailHheight, $thumbnailPath)\n                                    -\u003estore($mainImageFolder, $request-\u003efile('file'), $post-\u003etitle, $crop)\n                                    -\u003econvert()\n                                    -\u003egetStoredImagePath();\n            $post-\u003esave();\n                         \n        }\n             \n    }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaldreams%2Fphoto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitaldreams%2Fphoto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaldreams%2Fphoto/lists"}