{"id":19689157,"url":"https://github.com/Flowframe/laravel-trend","last_synced_at":"2025-04-29T08:35:08.417Z","repository":{"id":38833712,"uuid":"414543035","full_name":"Flowframe/laravel-trend","owner":"Flowframe","description":"Generate trends for your models. Easily generate charts or reports.","archived":false,"fork":false,"pushed_at":"2024-09-27T09:26:37.000Z","size":25,"stargazers_count":776,"open_issues_count":18,"forks_count":73,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-11T18:48:17.730Z","etag":null,"topics":["charts","data","hacktoberfest","laravel","package","php","reports","trends"],"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/Flowframe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"larsklopstra"}},"created_at":"2021-10-07T09:44:21.000Z","updated_at":"2024-11-11T08:06:27.000Z","dependencies_parsed_at":"2023-09-24T17:56:53.773Z","dependency_job_id":"3df6f49d-e5a0-4c6e-b2ca-f5e67e98e149","html_url":"https://github.com/Flowframe/laravel-trend","commit_stats":{"total_commits":15,"total_committers":9,"mean_commits":"1.6666666666666667","dds":0.6666666666666667,"last_synced_commit":"0461e38693486330bdebad3aa84976227c677d11"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flowframe%2Flaravel-trend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flowframe%2Flaravel-trend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flowframe%2Flaravel-trend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flowframe%2Flaravel-trend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flowframe","download_url":"https://codeload.github.com/Flowframe/laravel-trend/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251465269,"owners_count":21593852,"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":["charts","data","hacktoberfest","laravel","package","php","reports","trends"],"created_at":"2024-11-11T18:42:55.330Z","updated_at":"2025-04-29T08:35:08.149Z","avatar_url":"https://github.com/Flowframe.png","language":"PHP","funding_links":["https://github.com/sponsors/larsklopstra"],"categories":["PHP"],"sub_categories":[],"readme":"# Laravel Trend\n\nGenerate trends for your models. Easily generate charts or reports.\n\n## Why?\n\nMost applications require charts or reports to be generated. Doing this over again, and again can be a painful process. That's why we've created a fluent Laravel package to solve this problem.\n\nYou can aggregate average, min, max, and totals per minute, hour, day, month, and year.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\ncomposer require flowframe/laravel-trend\n```\n\n## Usage\n\nTo generate a trend for your model, import the `Flowframe\\Trend\\Trend` class and pass along a model or query.\n\nExample:\n\n```php\n// Totals per month\n$trend = Trend::model(User::class)\n    -\u003ebetween(\n        start: now()-\u003estartOfYear(),\n        end: now()-\u003eendOfYear(),\n    )\n    -\u003eperMonth()\n    -\u003ecount();\n\n// Average user weight where name starts with a over a span of 11 years, results are grouped per year\n$trend = Trend::query(User::where('name', 'like', 'a%'))\n    -\u003ebetween(\n        start: now()-\u003estartOfYear()-\u003esubYears(10),\n        end: now()-\u003eendOfYear(),\n    )\n    -\u003eperYear()\n    -\u003eaverage('weight');\n```\n\n## Starting a trend\n\nYou must either start a trend using `::model()` or `::query()`. The difference between the two is that using `::query()` allows you to add additional filters, just like you're used to using eloquent. Using `::model()` will just consume it as it is.\n\n```php\n// Model\nTrend::model(Order::class)\n    -\u003ebetween(...)\n    -\u003eperDay()\n    -\u003ecount();\n\n// More specific order query\nTrend::query(\n    Order::query()\n        -\u003ehasBeenPaid()\n        -\u003ehasBeenShipped()\n)\n    -\u003ebetween(...)\n    -\u003eperDay()\n    -\u003ecount();\n```\n\n## Interval\n\nYou can use the following aggregates intervals:\n\n-   `perMinute()`\n-   `perHour()`\n-   `perDay()`\n-   `perMonth()`\n-   `perYear()`\n\n## Aggregates\n\nYou can use the following aggregates:\n\n-   `sum('column')`\n-   `average('column')`\n-   `max('column')`\n-   `min('column')`\n-   `count('*')`\n\n## Date Column\n\nBy default, laravel-trend assumes that the model on which the operation is being performed has a `created_at` date column. If your model uses a different column name for the date or you want to use a different one, you should specify it using the `dateColumn(string $column)` method.\n\nExample:\n\n```php\nTrend::model(Order::class)\n    -\u003edateColumn('custom_date_column')\n    -\u003ebetween(...)\n    -\u003eperDay()\n    -\u003ecount();\n```\n\nThis allows you to work with models that have custom date column names or when you want to analyze data based on a different date column.\n\n## Drivers\n\nWe currently support four drivers:\n\n-   MySQL\n-   MariaDB\n-   SQLite\n-   PostgreSQL\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n-   [Lars Klopstra](https://github.com/flowframe)\n-   [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFlowframe%2Flaravel-trend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFlowframe%2Flaravel-trend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFlowframe%2Flaravel-trend/lists"}