{"id":25826532,"url":"https://github.com/webard/biloquent","last_synced_at":"2025-08-10T03:39:10.881Z","repository":{"id":216513866,"uuid":"741496494","full_name":"webard/biloquent","owner":"webard","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-13T00:16:01.000Z","size":86,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-10T03:39:10.103Z","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/webard.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}},"created_at":"2024-01-10T14:15:28.000Z","updated_at":"2024-01-10T15:56:24.000Z","dependencies_parsed_at":"2024-01-10T18:10:50.259Z","dependency_job_id":"6a432984-7b2e-435c-9ef8-9d7d9d2ff99f","html_url":"https://github.com/webard/biloquent","commit_stats":null,"previous_names":["webard/biloquent"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/webard/biloquent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webard%2Fbiloquent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webard%2Fbiloquent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webard%2Fbiloquent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webard%2Fbiloquent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webard","download_url":"https://codeload.github.com/webard/biloquent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webard%2Fbiloquent/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269672481,"owners_count":24457115,"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","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"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":[],"created_at":"2025-02-28T15:35:12.759Z","updated_at":"2025-08-10T03:39:10.860Z","avatar_url":"https://github.com/webard.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BILOQUENT\n\nReports for Eloquent models.\n\n**Package is under development and in very early stage.**\n\n\n## UDF Infusion\n\nSome of aggregator needs [UDF Infusion](https://github.com/infusion/udf_infusion) extensions for MySQL:\n\n- kurtosis\n- median\n- percentile\n- skewness\n\n## Sample report\n\nSample base on Order model with total and created_at fields required.\n\nCreate file `App\\Reports\\OrderReport.php`:\n\n```php\ndeclare(strict_types=1);\n\nnamespace App\\Reports;\n\nuse Webard\\Biloquent\\Aggregators\\Avg;\nuse Webard\\Biloquent\\Aggregators\\Count;\nuse Webard\\Biloquent\\Report;\nuse Illuminate\\Database\\Eloquent\\Relations\\BelongsTo;\nuse App\\Models\\User;\nuse App\\Models\\Order;\n\nclass OrderReport extends Report\n{\n    public static string $model = Order::class;\n   \n    // Defaults if not defined\n    public array $grouping = ['year'];\n    public array $columns = ['total_orders'];\n\n    // Define needed relations, they are not taken from source model (yet)\n    public function customer(): BelongsTo\n    {\n        return $this-\u003ebelongsTo(User::class, 'customer_id');\n    }\n\n    // Define aggregators\n    public function aggregators(): array\n    {\n         // It is good practice to alias column names, but not necessary\n        return [\n            'total_orders' =\u003e Count::field('total_orders', 'orders.id'),\n            'average_amount' =\u003e Avg::field('average_amount', 'orders.value'),\n        ];\n    }\n\n    public function groups(): array\n    {\n        // It is good practice to alias column names, but not necessary\n        return [\n            'day' =\u003e [\n                // aggregator will be applied to report query\n                'aggregator' =\u003e 'DAY(orders_created_at)',\n                // field will be fetched from dataset query\n                'field' =\u003e 'orders.created_at as orders_created_at'\n            ],\n            'month' =\u003e [\n                'aggregator' =\u003e 'MONTH(orders_created_at)',\n                'field' =\u003e 'orders.created_at as orders_created_at'\n            ],\n            'year' =\u003e [\n                'aggregator' =\u003e 'YEAR(orders_created_at)',\n                'field' =\u003e 'orders.created_at as orders_created_at'\n            ],\n            'date' =\u003e [\n                'aggregator' =\u003e 'DATE(orders_created_at)',\n                'field' =\u003e 'orders.created_at as orders_created_at'\n            ],\n            'channel_id' =\u003e [\n                'field' =\u003e 'channels.channel_id as channels_channel_id',\n                'aggregator' =\u003e 'channels_channel_id'\n            ],\n        ];\n    }\n}\n```\n\nNow you can use report:\n\n```php\n$report = OrderReport::query()\n    // set grouping fields\n    -\u003egrouping(['month', 'year'])\n    // set which data you want to calculate\n    -\u003esummary(['total_orders'])\n    // narrow down dataset that you want to calculate\n    -\u003eenhance(function($model) {\n        $model-\u003ewhereYear('created_at','\u003e=', '2023');\n    })\n    // prepare report (this needs to be called before running query)\n    -\u003eprepare()\n    // get results\n    -\u003eget();\n```\n\nExample output:\n```php\n[\n    0 =\u003e  [\n        'year' =\u003e 2023,\n        'month' =\u003e 12,\n        'total_orders' =\u003e 5,\n    ],\n    1 =\u003e  [\n        'year' =\u003e 2024,\n        'month' =\u003e 4,\n        'total_orders' =\u003e 2,\n    ],\n]\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebard%2Fbiloquent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebard%2Fbiloquent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebard%2Fbiloquent/lists"}