{"id":34001521,"url":"https://github.com/laravel-interaction/visit","last_synced_at":"2026-04-08T19:32:58.592Z","repository":{"id":45891817,"uuid":"319995769","full_name":"laravel-interaction/visit","owner":"laravel-interaction","description":"🔍 User visit behaviour for Laravel.","archived":false,"fork":false,"pushed_at":"2026-02-06T04:15:22.000Z","size":121,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-06T13:36:54.057Z","etag":null,"topics":["eloquent","laravel","visit"],"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/laravel-interaction.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2020-12-09T15:17:52.000Z","updated_at":"2024-05-10T15:24:31.000Z","dependencies_parsed_at":"2024-05-06T16:15:03.635Z","dependency_job_id":"88bd3195-f1e6-470d-8e3a-75e85e75367d","html_url":"https://github.com/laravel-interaction/visit","commit_stats":{"total_commits":91,"total_committers":5,"mean_commits":18.2,"dds":"0.34065934065934067","last_synced_commit":"59ae855510a9bdb2f813c8c7cd63f66962d6486c"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":"zingimmick/package-skeleton-laravel","purl":"pkg:github/laravel-interaction/visit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravel-interaction%2Fvisit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravel-interaction%2Fvisit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravel-interaction%2Fvisit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravel-interaction%2Fvisit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/laravel-interaction","download_url":"https://codeload.github.com/laravel-interaction/visit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/laravel-interaction%2Fvisit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31571600,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: 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":["eloquent","laravel","visit"],"created_at":"2025-12-13T09:54:05.456Z","updated_at":"2026-04-08T19:32:58.582Z","avatar_url":"https://github.com/laravel-interaction.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Visit\n\nUser visit behaviour for Laravel.\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://packagist.org/packages/laravel-interaction/visit\"\u003e\u003cimg src=\"https://poser.pugx.org/laravel-interaction/visit/v/stable.svg\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/laravel-interaction/visit\"\u003e\u003cimg src=\"https://poser.pugx.org/laravel-interaction/visit/downloads\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/laravel-interaction/visit\"\u003e\u003cimg src=\"https://poser.pugx.org/laravel-interaction/visit/v/unstable.svg\" alt=\"Latest Unstable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/laravel-interaction/visit\"\u003e\u003cimg src=\"https://poser.pugx.org/laravel-interaction/visit/license\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Introduction\n\nIt used to record the number of visits to the model(documentation/subject/question).\n\n![](https://img.shields.io/badge/%F0%9F%93%96-1.2k-green?style=social)\n\n## Installation\n\n### Requirements\n\n- [PHP 8.0+](https://php.net/releases/)\n- [Composer](https://getcomposer.org)\n- [Laravel 8.0+](https://laravel.com/docs/releases)\n\n### Instructions\n\nRequire Laravel Visit using [Composer](https://getcomposer.org).\n\n```bash\ncomposer require laravel-interaction/visit\n```\n\nPublish configuration and migrations\n\n```bash\nphp artisan vendor:publish --tag=visit-config\nphp artisan vendor:publish --tag=visit-migrations\n```\n\nRun database migrations.\n\n```bash\nphp artisan migrate\n```\n\n## Usage\n\n### Setup Visitor\n\n```php\nuse Illuminate\\Database\\Eloquent\\Model;\nuse LaravelInteraction\\Visit\\Concerns\\Visitor;\n\nclass User extends Model\n{\n    use Visitor;\n}\n```\n\n### Setup Visitable\n\n```php\nuse Illuminate\\Database\\Eloquent\\Model;\nuse LaravelInteraction\\Visit\\Concerns\\Visitable;\n\nclass Subject extends Model\n{\n    use Visitable;\n}\n```\n\n### Visitor\n\n```php\nuse LaravelInteraction\\Visit\\Tests\\Models\\Subject;\n/** @var \\LaravelInteraction\\Visit\\Tests\\Models\\User $user */\n/** @var \\LaravelInteraction\\Visit\\Tests\\Models\\Subject $subject */\n// Visit to Visitable\n$user-\u003evisit($subject);\n\n// Compare Visitable\n$user-\u003ehasVisited($subject);\n$user-\u003ehasNot\nVisited($subject);\n\n// Get visited info\n$user-\u003evisitVisitors()-\u003ecount(); \n\n// with type\n$user-\u003evisitVisitors()-\u003ewithType(Subject::class)-\u003ecount(); \n\n// get visited subjects\nSubject::query()-\u003ewhereVisitedBy($user)-\u003eget();\n\n// get subjects doesnt visited\nSubject::query()-\u003ewhereNotVisitedBy($user)-\u003eget();\n```\n\n### Visitable\n\n```php\nuse LaravelInteraction\\Visit\\Tests\\Models\\User;\nuse LaravelInteraction\\Visit\\Tests\\Models\\Subject;\n/** @var \\LaravelInteraction\\Visit\\Tests\\Models\\User $user */\n/** @var \\LaravelInteraction\\Visit\\Tests\\Models\\Subject $subject */\n// Compare Visitor\n$subject-\u003eisVisitedBy($user); \n$subject-\u003eisNotVisitedBy($user);\n// Get visitors info\n$subject-\u003evisitors-\u003eeach(function (User $user){\n    echo $user-\u003egetKey();\n});\n\n$subjects = Subject::query()-\u003ewithVisitorsCount()-\u003eget();\n$subjects-\u003eeach(function (Subject $subject){\n    // like uv\n    echo $subject-\u003evisitors()-\u003ecount(); // 1100\n    echo $subject-\u003evisitors_count; // \"1100\"\n    echo $subject-\u003evisitorsCount(); // 1100\n    echo $subject-\u003evisitorsCountForHumans(); // \"1.1K\"\n    // like pv\n    echo $subject-\u003evisitableVisits()-\u003ecount(); // 1100\n    echo $subject-\u003evisits_count; // \"1100\"\n    echo $subject-\u003evisitsCount(); // 1100\n    echo $subject-\u003evisitsCountForHumans(); // \"1.1K\"\n});\n$subjects = Subject::query()-\u003ewithVisitorsCount(function ($query){\n    return $query-\u003ewhereKey(1);\n})-\u003eget();\n```\n\n## With Api Request\n\n```php\nuse Illuminate\\Http\\Request;\nuse Illuminate\\Routing\\Controller;\nuse LaravelInteraction\\Visit\\Tests\\Models\\Subject;\nuse Illuminate\\Http\\Resources\\Json\\JsonResource;\n\nclass AuctionController extends Controller\n{\n    public function show($id, Request $request){\n        $subject = Subject::query()-\u003efindOrFail($id);\n        dispatch(function () use ($subject, $request) {\n            $subject-\u003erecord($request);\n        })-\u003eafterResponse();\n        return new JsonResource($subject);\n    }\n}\n```\n\n### Events\n\n| Event | Fired |\n| --- | --- |\n| `LaravelInteraction\\Visit\\Events\\Visited` | When an object get visited. |\n\n## License\n\nLaravel Eloquent Visit is an open-sourced software licensed under the [MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaravel-interaction%2Fvisit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flaravel-interaction%2Fvisit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flaravel-interaction%2Fvisit/lists"}