{"id":18537956,"url":"https://github.com/shetabit/visitor","last_synced_at":"2026-02-28T08:10:49.195Z","repository":{"id":38709207,"uuid":"214968423","full_name":"shetabit/visitor","owner":"shetabit","description":"a laravel package to work with visitors and retrieve their informations","archived":false,"fork":false,"pushed_at":"2026-02-18T15:33:08.000Z","size":89,"stargazers_count":563,"open_issues_count":9,"forks_count":76,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-02-18T19:37:25.875Z","etag":null,"topics":["laravel","laravel-online-users","visitor-information"],"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/shetabit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2019-10-14T06:48:32.000Z","updated_at":"2026-02-18T15:32:46.000Z","dependencies_parsed_at":"2024-06-18T13:57:24.424Z","dependency_job_id":"3fce8cba-bb70-4115-9c7b-a657ceb990a7","html_url":"https://github.com/shetabit/visitor","commit_stats":{"total_commits":31,"total_committers":15,"mean_commits":2.066666666666667,"dds":0.6451612903225806,"last_synced_commit":"56800438f6facb868e5ccaab0c252f10aec1d505"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"purl":"pkg:github/shetabit/visitor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetabit%2Fvisitor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetabit%2Fvisitor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetabit%2Fvisitor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetabit%2Fvisitor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shetabit","download_url":"https://codeload.github.com/shetabit/visitor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shetabit%2Fvisitor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29928298,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T19:37:42.220Z","status":"online","status_checked_at":"2026-02-28T02:00:07.010Z","response_time":90,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["laravel","laravel-online-users","visitor-information"],"created_at":"2024-11-06T19:41:26.346Z","updated_at":"2026-02-28T08:10:49.133Z","avatar_url":"https://github.com/shetabit.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\u003cimg width=\"200\" src=\"resources/images/visitor.png?raw=true\"\u003e\u003c/p\u003e\n\n# Laravel Visitor\n\nThis is a laravel package to extract and access visitors' information such as `browser`, `ip`, `device` and etc.\n\n**In this package, you can recognize online users and determine if a user is online or not**\n\n### Install\n\nVia composer\n\n```bash\ncomposer require shetabit/visitor\n```\n\n### Configure\n\nIf you are using Laravel 5.5 or higher then you don't need to add the provider and alias.\n\n```php\n# In your providers array.\n'providers' =\u003e [\n    ...\n    Shetabit\\Visitor\\Provider\\VisitorServiceProvider::class,\n],\n\n# In your aliases array.\n'aliases' =\u003e [\n    ...\n    'Visitor' =\u003e Shetabit\\Visitor\\Facade\\Visitor::class,\n],\n```\n\nThen, run the below commands to publish migrations and create tables\n\n```bash\nphp artisan vendor:publish\n\nphp artisan migrate\n```\n\n### How to use\n\nYou can access to `visitor's information` using `$request-\u003evisitor()` in your controllers , and  you can access to the visitor's information using `visitor()` helper function any where.\n\nWe have the below methods to retrieve a visitor's information:\n\n- `device` : device's name\n- `platform` : platform's name\n- `browser` : browser's name\n- `languages` : language's name\n- `ip` : client's ip\n- `request` : the whole request inputs\n- `useragent` : the whole useragent\n- `isOnline` : determines if current (or given) user is online\n\n```php\n$request-\u003evisitor()-\u003ebrowser(); // firefox\n$request-\u003evisitor()-\u003evisit($post); // create log for post\n$request-\u003evisitor()-\u003esetVisitor($user)-\u003evisit($post); // create a log which says $user has visited $post\n```\n\n#### Store Logs\n\nYou can create logs using the `visit` method like the below\n\n```php\nvisitor()-\u003evisit(); // create a visit log\n```\n\nuse `Shetabit\\Visitor\\Traits\\Visitable` trait in your models, then you can save visit's log for your models like the below\n\n```php\n// or you can save log like the below\nvisitor()-\u003evisit($model);\n// or like the below\n$model-\u003ecreateVisitLog();\n\n// you can say which user has visited the given $model\n$model-\u003ecreateVisitLog($user);\n// or like the below\nvisitor()-\u003esetVisitor($user)-\u003evisit($model);\n\n```\n\nModel views can be loaded using `visits` relation.\n\nYou can count model visits like the below\n\n```php\n$model-\u003evisitLogs()-\u003ecount();\n```\nunique users can be counted by their IP and by model.\n\n```php\n// by ip\n$model-\u003evisitLogs()-\u003edistinct('ip')-\u003ecount('ip');\n\n// by user's model\n$model-\u003evisitLogs()-\u003evisitor()-\u003ecount();\n```\n\nuse `Shetabit\\Visitor\\Traits\\Visitor` in your `User` class, then you can run below codes\n\n ```php\n$user-\u003evisit(); // create a visit log\n$user-\u003evisit($model); // create a log which says, $user has visited $model\n ```\n\n#### Retrieve and Determine Online users\n\nuse `Shetabit\\Visitor\\Traits\\Visitor` in your `User` class at first.\n\nThen you can retrieve online users which are instance of `User` class and determine if a user is online.\n\n```php\nvisitor()-\u003eonlineVisitors(User::class); // returns collection of online users\nUser::online()-\u003eget(); // another way\n\nvisitor()-\u003eisOnline($user); // determines if the given user is online\n$user-\u003eisOnline(); // another way\n```\n\n#### Automatic logging\n\nYour application can store visitor's log automatically using `LogVisits` middleware.\n\nAdd the `Shetabit\\Visitor\\Middlewares\\LogVisits` middleware if you want to save logs automatically.\n\nThe middleware will store logs for models which has binded in router (router model binding) and has used `Shetabit\\Visitor\\Traits\\Visitable` trait.\n\n## Star History\n\n[![Star History Chart](https://api.star-history.com/svg?repos=shetabit/visitor\u0026type=Date)](https://star-history.com/#shetabit/visitor\u0026Date)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshetabit%2Fvisitor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshetabit%2Fvisitor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshetabit%2Fvisitor/lists"}