{"id":19706732,"url":"https://github.com/unisharp/ratable","last_synced_at":"2026-05-16T05:15:03.361Z","repository":{"id":57075567,"uuid":"130158092","full_name":"UniSharp/ratable","owner":"UniSharp","description":"Provide a trait to multiple models to rate easliy","archived":false,"fork":false,"pushed_at":"2018-05-23T11:09:19.000Z","size":25,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-01-10T12:49:07.470Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/UniSharp.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":"2018-04-19T04:16:08.000Z","updated_at":"2018-05-23T11:09:20.000Z","dependencies_parsed_at":"2022-08-24T14:55:44.496Z","dependency_job_id":null,"html_url":"https://github.com/UniSharp/ratable","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Fratable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Fratable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Fratable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UniSharp%2Fratable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UniSharp","download_url":"https://codeload.github.com/UniSharp/ratable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241021009,"owners_count":19895541,"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":[],"created_at":"2024-11-11T21:36:41.519Z","updated_at":"2026-05-16T05:15:03.317Z","avatar_url":"https://github.com/UniSharp.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ratable\n\nProvide a trait to multiple models to rate easliy.\n\n## Installation\n\n```\ncomposer require unisharp/ratable dev-master\n```\n\n## Configuration\n\nSet provider modules in `config/app.php`\n\n```php\nreturn [\n    'providers' =\u003e [\n          UniSharp\\Ratable\\Providers\\RatableServiceProvider:class\n    ]\n];\n```\n\n## Usages\n\nUse trait in the model\n\n```php\n\nnamespace App;\n\nuse Illuminate\\Database\\Eloquent\\Model;\nuse UniSharp\\Ratable\\Traits\\Ratable;\n\nclass Movie extends Model\n{\n    use Ratable;\n}\n```\n\nRate your model with grade and/or description\n\n```php\n\n$movie = new Movie();\n\n$movie-\u003erates()-\u003ecreate([\n  'grade' =\u003e 10,\n  'description' =\u003e 'Excellent'\n]);\n\n```\n\nGet your model's average rate\n\n```php\n\n$movie = new Movie();\n\n$movie-\u003erates()-\u003esaveMany(\n  new UniSharp\\Ratable\\Models\\Rate(['grade' =\u003e 10, 'description' =\u003e 'Excellent'],\n  new UniSharp\\Ratable\\Models\\Rate(['grade' =\u003e 5, 'description' =\u003e 'Not Bad']\n);\n\n$movie-\u003eaverage()  // 7.5\n\n```\n\nGet a rate's giver and model\n\n```php\n$movie = new Movie();\n\n$rate = $movie-\u003erates()-\u003ecreate([\n  'grade' =\u003e 10,\n  'description' =\u003e 'Excellent'\n]);\n\n// giver\n$rate-\u003euser;\n\n// model\n$rate-\u003eratable;\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funisharp%2Fratable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funisharp%2Fratable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funisharp%2Fratable/lists"}