{"id":21254084,"url":"https://github.com/jobmetric/laravel-like","last_synced_at":"2025-07-11T01:33:30.739Z","repository":{"id":239218670,"uuid":"764325997","full_name":"jobmetric/laravel-like","owner":"jobmetric","description":"This is a likes management package for any object in Laravel that you can use in your projects.","archived":false,"fork":false,"pushed_at":"2024-07-25T18:49:52.000Z","size":20,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-14T20:22:44.113Z","etag":null,"topics":["laravel","laravel-package","like","like-count","likeable","likes","package"],"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/jobmetric.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"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}},"created_at":"2024-02-27T21:55:16.000Z","updated_at":"2024-07-25T18:49:45.000Z","dependencies_parsed_at":"2024-07-25T21:45:09.179Z","dependency_job_id":null,"html_url":"https://github.com/jobmetric/laravel-like","commit_stats":null,"previous_names":["jobmetric/laravel-like"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jobmetric%2Flaravel-like","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jobmetric%2Flaravel-like/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jobmetric%2Flaravel-like/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jobmetric%2Flaravel-like/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jobmetric","download_url":"https://codeload.github.com/jobmetric/laravel-like/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225669573,"owners_count":17505386,"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":["laravel","laravel-package","like","like-count","likeable","likes","package"],"created_at":"2024-11-21T03:54:08.889Z","updated_at":"2024-11-21T03:54:09.454Z","avatar_url":"https://github.com/jobmetric.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[contributors-shield]: https://img.shields.io/github/contributors/jobmetric/laravel-like.svg?style=for-the-badge\r\n[contributors-url]: https://github.com/jobmetric/laravel-like/graphs/contributors\r\n[forks-shield]: https://img.shields.io/github/forks/jobmetric/laravel-like.svg?style=for-the-badge\u0026label=Fork\r\n[forks-url]: https://github.com/jobmetric/laravel-like/network/members\r\n[stars-shield]: https://img.shields.io/github/stars/jobmetric/laravel-like.svg?style=for-the-badge\r\n[stars-url]: https://github.com/jobmetric/laravel-like/stargazers\r\n[license-shield]: https://img.shields.io/github/license/jobmetric/laravel-like.svg?style=for-the-badge\r\n[license-url]: https://github.com/jobmetric/laravel-like/blob/master/LICENCE.md\r\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-blue.svg?style=for-the-badge\u0026logo=linkedin\u0026colorB=555\r\n[linkedin-url]: https://linkedin.com/in/majidmohammadian\r\n\r\n[![Contributors][contributors-shield]][contributors-url]\r\n[![Forks][forks-shield]][forks-url]\r\n[![Stargazers][stars-shield]][stars-url]\r\n[![MIT License][license-shield]][license-url]\r\n[![LinkedIn][linkedin-shield]][linkedin-url]\r\n\r\n# Like for laravel\r\n\r\nThis is a like management package for Laravel that you can use in your projects.\r\n\r\n## Install via composer\r\n\r\nRun the following command to pull in the latest version:\r\n```bash\r\ncomposer require jobmetric/laravel-like\r\n```\r\n\r\n## Documentation\r\n\r\nThis package evolves every day under constant development and integrates a diverse set of features. It is a must-have asset for Laravel enthusiasts and provides a seamless way to coordinate your projects with like and dislike base models.\r\n\r\nIn this package, you can use it seamlessly with any model that requires likes and dislikes.\r\n\r\nNow let's move on to the main function.\r\n\r\n\u003e#### Before doing anything, you must migrate after installing the package by composer.\r\n\r\n```bash\r\nphp artisan migrate\r\n```\r\n\r\nMeet the `HasLike` class, meticulously designed for integration into your model. This class automates essential tasks, ensuring a streamlined process for:\r\n\r\nIn the first step, you need to connect this class to your main model.\r\n\r\n```php\r\nuse JobMetric\\Like\\HasLike;\r\n\r\nclass Post extends Model\r\n{\r\n    use HasLike;\r\n}\r\n```\r\n\r\n## How is it used?\r\n\r\nYou can now use the `HasLike` class for your model. The following example shows how to create a new post with a like:\r\n\r\n```php\r\n$post = Post::create([\r\n    'status' =\u003e 'published',\r\n]);\r\n\r\n$user_id = 1;\r\n\r\n$post-\u003elikeIt($user_id, $type = true);\r\n```\r\n\r\n\u003e The `likeIt` function is used to like the post. The first parameter is the user id, and the second parameter is the type of like. If you want to dislike, you can set it to `false`.\r\n\r\n### Now we go to the functions that we have added to our model.\r\n\r\n#### likeOne\r\n\r\nlike has one relationship\r\n\r\n#### likes\r\n\r\nlike has many relationships\r\n\r\n#### likeTo\r\n\r\nscope locale for select like relationship\r\n\r\n#### dislikeTo\r\n\r\nscope locale for select disLike relationship\r\n\r\n#### likesTo\r\n\r\nscope locale for select likes relationship\r\n\r\n#### dislikesTo\r\n\r\nscope locale for select disLikes relationship\r\n\r\n#### likeIt\r\n\r\nThis function is very important and is used to store user's likes and dislikes.\r\n\r\n```php\r\n$post-\u003elikeIt($user_id, $type = true);\r\n```\r\n\r\n\u003e The `likeIt` function is used to like the post. The first parameter is the user id, and the second parameter is the type of like. If you want to dislike, you can set it to `false`.\r\n\u003e user_id: user id\r\n\u003e type: like or dislike\r\n\r\n#### likeCount\r\n\r\nget count of likes\r\n\r\n#### dislikeCount\r\n\r\nget count of dislikes\r\n\r\n#### loadLikeDislikeCount\r\n\r\nThis function helps to see the number of likes and dislikes of each object and loads it in the desired model.\r\n\r\n```php\r\n$post-\u003eloadLikeDislikeCount();\r\n```\r\n\r\n#### loadLikeDislike\r\n\r\nload like or disLike after model loaded\r\n\r\n\u003e The `loadLikeDislike` function is used to load the likes and dislikes of the object after the model is loaded.\r\n\r\n#### loadLikesDislikes\r\n\r\nload likes or dislikes after model loaded\r\n\r\n\u003e The `loadLikesDislikes` function is used to load the likes and dislikes of the object after the model is loaded.\r\n\r\n#### isLikedDislikedBy\r\n\r\nis liked or disliked by user\r\n\r\n```php\r\n$type = $post-\u003eisLikedDislikedBy($user_id);\r\n\r\nif(\\JobMetric\\Like\\Enums\\LikeTypeEnum::LIKE == $type) {\r\n    // liked\r\n} else if(\\JobMetric\\Like\\Enums\\LikeTypeEnum::DISLIKE == $type) {\r\n    // disliked\r\n} else {\r\n    // not liked or disliked\r\n}\r\n```\r\n\r\n#### forgetLike\r\n\r\nforget like or dislike\r\n\r\n```php\r\n$post-\u003eforgetLike($user_id);\r\n```\r\n\r\n#### forgetLikes\r\n\r\nforget likes or dislikes\r\n\r\n```php\r\n$post-\u003eforgetLikes();\r\n```\r\n\r\n## Contributing\r\n\r\nThank you for considering contributing to the Laravel Like! The contribution guide can be found in the [CONTRIBUTING.md](https://github.com/jobmetric/laravel-like/blob/master/CONTRIBUTING.md).\r\n\r\n## License\r\n\r\nThe MIT License (MIT). Please see [License File](https://github.com/jobmetric/laravel-like/blob/master/LICENCE.md) for more information.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjobmetric%2Flaravel-like","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjobmetric%2Flaravel-like","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjobmetric%2Flaravel-like/lists"}