{"id":24725488,"url":"https://github.com/learncodeweb/activity-log","last_synced_at":"2026-04-24T21:31:31.281Z","repository":{"id":234401445,"uuid":"595999107","full_name":"LearnCodeWeb/Activity-Log","owner":"LearnCodeWeb","description":"save all dashboard panel activity","archived":false,"fork":false,"pushed_at":"2026-03-16T03:08:32.000Z","size":105,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-16T13:16:00.700Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Blade","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/LearnCodeWeb.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}},"created_at":"2023-02-01T08:51:18.000Z","updated_at":"2026-03-16T03:08:35.000Z","dependencies_parsed_at":"2024-04-19T07:42:05.204Z","dependency_job_id":"90354b27-8928-4dcc-a98a-f4980abe6c14","html_url":"https://github.com/LearnCodeWeb/Activity-Log","commit_stats":null,"previous_names":["learncodeweb/activity-log"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/LearnCodeWeb/Activity-Log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LearnCodeWeb%2FActivity-Log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LearnCodeWeb%2FActivity-Log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LearnCodeWeb%2FActivity-Log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LearnCodeWeb%2FActivity-Log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LearnCodeWeb","download_url":"https://codeload.github.com/LearnCodeWeb/Activity-Log/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LearnCodeWeb%2FActivity-Log/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32241569,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-24T13:21:15.438Z","status":"ssl_error","status_checked_at":"2026-04-24T13:21:15.005Z","response_time":64,"last_error":"SSL_read: 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":[],"created_at":"2025-01-27T13:19:30.043Z","updated_at":"2026-04-24T21:31:31.275Z","avatar_url":"https://github.com/LearnCodeWeb.png","language":"Blade","readme":"# 🗂️ Laravel Activity Log\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/learncodeweb/activitylog.svg?style=flat-square)](https://packagist.org/packages/learncodeweb/activitylog)\n[![Total Downloads](https://img.shields.io/packagist/dt/learncodeweb/activitylog.svg?style=flat-square)](https://packagist.org/packages/learncodeweb/activitylog)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![PHP Version](https://img.shields.io/badge/PHP-%3E%3D7.0-blue.svg)](https://php.net)\n\nA simple and powerful **Activity Log** package for Laravel. It automatically tracks and records every user action in your admin or user panel after login — no complex setup needed.\n\n\u003e ✅ Tested with **Laravel 8, 9, 10, 11, 12**\n\n---\n\n## ✨ Features\n\n- 🔍 Automatically logs all authenticated user activity\n- 🚫 Ignore specific routes you don't want to track\n- 🗑️ Auto-delete old logs based on configurable time limit\n- 📋 Built-in default view to see all logs at `/log`\n- 🛠️ Create custom logs manually with full control\n- ⚡ Easy installation via Composer\n\n---\n\n## 📋 Requirements\n\n| Requirement | Version |\n|-------------|---------|\n| PHP | \u003e= 7.0 |\n| Laravel | \u003e= 8.x |\n| Guzzle HTTP | ^7.0 |\n\n---\n\n## 🚀 Installation\n\nInstall the package via Composer:\n\n```bash\ncomposer require learncodeweb/activitylog\n```\n\n### Register Service Provider\n\n\u003e ⚠️ **Important:** This package does **not** support Laravel's auto-discovery. You **must** manually register the service provider based on your Laravel version.\n\n---\n\n#### Laravel 8, 9, 10 — `config/app.php`\n\nOpen `config/app.php` and add inside the `providers` array:\n\n```php\n/*\n * Package Service Providers...\n */\nLcw\\Activitylog\\Providers\\ActivityLogProvider::class,\n```\n\n---\n\n#### Laravel 11 \u0026 12 — `bootstrap/providers.php`\n\nLaravel 11 and 12 **no longer use** `config/app.php` for providers. Instead, open `bootstrap/providers.php` and add:\n\n```php\n\u003c?php\n\nreturn [\n    App\\Providers\\AppServiceProvider::class,\n    Lcw\\Activitylog\\Providers\\ActivityLogProvider::class, // ✅ Add this line\n];\n```\n\n---\n\n## 🗄️ Database Setup\n\n### Step 1 — Publish Migration\n\n```bash\nphp artisan vendor:publish --provider=\"Lcw\\Activitylog\\Providers\\ActivityLogProvider\" --tag=\"migrations\"\n```\n\n### Step 2 — Run Migration\n\n```bash\nphp artisan migrate\n```\n\nThis creates the `activity_logs` table in your database.\n\n---\n\n## ⚙️ Configuration (Optional)\n\nExport the config file to customize settings:\n\n```bash\nphp artisan vendor:publish --provider=\"Lcw\\Activitylog\\Providers\\ActivityLogProvider\" --tag=\"config\"\n```\n\nThis creates `config/lcw_activity_log_config.php`. Below are the available options:\n\n```php\n\u003c?php\n\nreturn [\n\n    /*\n    |--------------------------------------------------------------------------\n    | Delete Limit\n    |--------------------------------------------------------------------------\n    | Set how many months of old logs to keep before auto-deletion.\n    | Default: 3 months\n    */\n    'delete_limit' =\u003e 3,\n\n    /*\n    |--------------------------------------------------------------------------\n    | Ignore Routes\n    |--------------------------------------------------------------------------\n    | List route names or URIs where you do NOT want activity to be logged.\n    | Example: dashboard index, file downloads, etc.\n    */\n    'ignore_routes' =\u003e [\n        'dashboard.index',\n        'settings.download.history.activity_log',\n    ],\n\n];\n```\n\n---\n\n## 📖 Usage\n\n### View Logs (Default Built-in View)\n\nThe package automatically provides a log viewer at:\n\n```\nhttp://your-domain.com/log\n```\n\n**Route name:** `lcw_activity_log_index`\n\n---\n\n### Get Logs in Your Own Controller\n\nYou can fetch logs manually and display them in your own view:\n\n```php\nuse Lcw\\Activitylog\\ActivityLog;\n\npublic function index(Request $request)\n{\n    $activityLog = new ActivityLog();\n    $logs = $activityLog-\u003eget($request);\n\n    return view('your-view', compact('logs'));\n}\n```\n\n---\n\n### Delete Old Logs\n\nDelete logs older than a given number of months:\n\n```php\nuse Lcw\\Activitylog\\ActivityLog;\n\n$activityLog = new ActivityLog();\n\n// Delete logs older than 1 month\n$activityLog-\u003elogDelete(1);\n\n// Delete logs older than 3 months\n$activityLog-\u003elogDelete(3);\n```\n\n---\n\n### Create a Custom Log Entry\n\nYou can manually create a log entry with custom data:\n\n```php\nuse Lcw\\Activitylog\\ActivityLog;\n\n$activityLog = new ActivityLog();\n\n$activityLog-\u003ecreate([\n    'log'          =\u003e 'User updated their notification settings',\n    'query_string' =\u003e $request-\u003eall(),\n]);\n```\n\n#### Available Parameters for `create()`\n\n| Parameter | Type | Description |\n|-----------|------|-------------|\n| `log` | `string` | A description of the activity |\n| `server_ip` | `string` | The server's IP address |\n| `user_ip` | `string` | The client/user's IP address |\n| `route_detail` | `array` | Array with current route path details |\n| `query_string` | `array` | Array of request parameters |\n| `user_id` | `int` | Authenticated user's ID |\n| `user` | `array` | Array of authenticated user data |\n| `created_at` | `datetime` | Custom timestamp for the log entry |\n\n---\n\n## 🔒 Ignoring Routes\n\nTo skip logging on specific routes, publish the config (see above) and add route **names** or **URIs** to the `ignore_routes` array:\n\n```php\n'ignore_routes' =\u003e [\n    'dashboard.index',           // by route name\n    'api/health-check',          // by URI\n    'settings.download.history.activity_log',\n],\n```\n\n---\n\n## 📁 Package Structure\n\n```\nsrc/\n├── ActivityLog.php              # Core activity log class\n├── Providers/\n│   └── ActivityLogProvider.php  # Service provider\n├── Http/\n│   └── Middleware/              # Auto-logging middleware\n├── Models/\n│   └── ActivityLogModel.php     # Eloquent model\n├── database/\n│   └── migrations/              # Migration files\n├── config/\n│   └── lcw_activity_log_config.php  # Config file\n└── resources/\n    └── views/                   # Default log viewer blade templates\n```\n\n---\n\n## 🧪 Example: Full Controller Usage\n\n```php\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\nuse Lcw\\Activitylog\\ActivityLog;\n\nclass ActivityLogController extends Controller\n{\n    protected $activityLog;\n\n    public function __construct()\n    {\n        $this-\u003eactivityLog = new ActivityLog();\n    }\n\n    // Show all activity logs\n    public function index(Request $request)\n    {\n        $logs = $this-\u003eactivityLog-\u003eget($request);\n        return view('admin.activity-log', compact('logs'));\n    }\n\n    // Delete logs older than X months\n    public function deleteOld(Request $request)\n    {\n        $months = $request-\u003einput('months', 3);\n        $this-\u003eactivityLog-\u003elogDelete($months);\n\n        return back()-\u003ewith('success', 'Old logs deleted successfully!');\n    }\n\n    // Manually log a custom action\n    public function logCustomAction()\n    {\n        $this-\u003eactivityLog-\u003ecreate([\n            'log' =\u003e 'Admin exported the user report',\n        ]);\n\n        return back()-\u003ewith('success', 'Action logged!');\n    }\n}\n```\n\n---\n\n## 🏢 Multi-Tenant Setup (stancl/tenancy)\n\nAgar aap `stancl/tenancy` (tenancy-for-laravel) use kar rahe hain toh neeche diye steps follow karo. Is package ki migration **tenant database** mein hogi aur har tenant apna alag activity log rakhega.\n\n---\n\n### Step 1 — Migration Publish Karke Tenant Folder Mein Move Karo\n\n`stancl/tenancy` mein tenant migrations `database/migrations/tenant/` folder mein honi chahiye.\n\n```bash\n# Pehle publish karo\nphp artisan vendor:publish --provider=\"Lcw\\Activitylog\\Providers\\ActivityLogProvider\" --tag=\"migrations\"\n\n# Phir tenant folder mein move karo\nmv database/migrations/*_create_activity_log_master.php database/migrations/tenant/\n```\n\n---\n\n### Step 2 — Tenancy Config Mein Migration Path Confirm Karo\n\n`config/tenancy.php` mein check karo ke tenant migrations ka path sahi set hai:\n\n```php\n'migration_parameters' =\u003e [\n    '--path'     =\u003e ['/database/migrations/tenant'],\n    '--realpath' =\u003e true,\n    '--force'    =\u003e true,\n],\n```\n\n---\n\n### Step 3 — Tenant Migration Run Karo\n\n```bash\n# Sab tenants par migrate karo\nphp artisan tenants:migrate\n\n# Sirf ek specific tenant par migrate karo\nphp artisan tenants:migrate --tenants=your-tenant-id\n```\n\nYeh command **har tenant ke alag database** mein `activity_log_master` table create kar degi.\n\n---\n\n### Step 4 — Naye Tenant Par Auto Migration\n\nJab naya tenant create ho toh automatically migration run ho — `app/Providers/TenancyServiceProvider.php` mein confirm karo ke yeh configured hai:\n\n```php\nuse Stancl\\Tenancy\\Events;\nuse Stancl\\Tenancy\\Jobs\\MigrateDatabase;\n\n'listeners' =\u003e [\n    Events\\TenantCreated::class =\u003e [\n        MigrateDatabase::class, // ✅ Naye tenant par auto migrate hoga\n    ],\n],\n```\n\nAgar yeh set hai toh har naye tenant ke create hone par `activity_log_master` table automatically ban jayega.\n\n---\n\n### Step 5 — Tenant Context Mein Normal Use Karo\n\n`stancl/tenancy` automatically tenant ka database switch karta hai. Package bilkul normal tarah use karo — har tenant ka data automatically uske apne database mein jayega:\n\n```php\nuse Lcw\\Activitylog\\ActivityLog;\n\n$activityLog = new ActivityLog();\n\n// Logs fetch karo (current tenant ka database use hoga automatically)\n$logs = $activityLog-\u003eget($request);\n\n// Custom log banana\n$activityLog-\u003ecreate([\n    'log' =\u003e 'User ne invoice download ki',\n]);\n\n// Purane logs delete karo\n$activityLog-\u003elogDelete(3);\n```\n\n---\n\n### Step 6 — Central App Se Specific Tenant Ka Log Dekhna\n\nAgar aap central panel se kisi specific tenant ka log access karna chahte hain:\n\n```php\nuse Lcw\\Activitylog\\ActivityLog;\n\n$tenant = \\App\\Models\\Tenant::find('tenant-id');\n\ntenancy()-\u003einitialize($tenant);\n\n$activityLog = new ActivityLog();\n$logs = $activityLog-\u003eget($request);\n\ntenancy()-\u003eend();\n\nreturn view('admin.tenant-logs', compact('logs'));\n```\n\n---\n\n### Tenant Default Log View\n\nTenant subdomain ya domain par default log view is URL par milega:\n\n```\nhttp://tenant1.yourdomain.com/log\n```\n\nHar tenant ka `/log` sirf **usi tenant ka data** dikhayega.\n\n---\n\n### Tenant Setup — Quick Reference\n\n| Task | Command |\n|------|---------|\n| Migration publish karo | `php artisan vendor:publish --tag=\"migrations\"` |\n| Migration move karo | `database/migrations/tenant/` folder mein |\n| Sab tenants migrate karo | `php artisan tenants:migrate` |\n| Single tenant migrate karo | `php artisan tenants:migrate --tenants=id` |\n| Tenant rollback karo | `php artisan tenants:migrate --rollback` |\n| Config publish karo | `php artisan vendor:publish --tag=\"config\"` |\n\n---\n\n## ❓ FAQ\n\n**Q: Does it log guest (unauthenticated) users?**  \nA: No, this package is designed for logged-in users only. It works best inside admin/user panels after authentication.\n\n**Q: Can I use my own view instead of the default `/log` page?**  \nA: Yes! Use `$activityLog-\u003eget($request)` in your controller and pass the data to your own Blade view.\n\n**Q: How do I stop certain pages from being logged?**  \nA: Publish the config file and add those route names or URIs to the `ignore_routes` array.\n\n**Q: Does it work with Laravel 12?**  \nA: Yes, but you must manually register the provider in `bootstrap/providers.php` — see the [Register Service Provider](#register-service-provider) section above.\n\n**Q: Does it support multi-tenancy with stancl/tenancy?**  \nA: Yes! Move the published migration to `database/migrations/tenant/`, run `php artisan tenants:migrate`, and the package will work per-tenant automatically. See the [Multi-Tenant Setup](#-multi-tenant-setup-stancltenancy) section for full details.\n\n---\n\n## 🤝 Contributing\n\nContributions, issues, and feature requests are welcome!  \nFeel free to open an [issue](https://github.com/LearnCodeWeb/Activity-Log/issues) or submit a pull request.\n\n---\n\n## 📄 License\n\nThis package is open-sourced software licensed under the [MIT License](LICENSE).\n\n---\n\n## 👨‍💻 Author\n\n**Mian Zaid (Khalid Zaid)**  \n🌐 [quran.ahlesunat.com](https://quran.ahlesunat.com)  \n📧 zaidbinkhalid31@gmail.com  \n📦 [Packagist](https://packagist.org/packages/learncodeweb/activitylog) | [GitHub](https://github.com/LearnCodeWeb/Activity-Log)\n\n---\n\n\u003e If this package helped you, please consider giving it a ⭐ on GitHub!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearncodeweb%2Factivity-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flearncodeweb%2Factivity-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearncodeweb%2Factivity-log/lists"}