blumilksoftware / laravel-heatmap
Heatmap library for Laravel
v1.0.0
2024-07-09 23:42 UTC
Requires
- php: ^8.2
- blumilksoftware/heatmap: 0.0.2
- illuminate/database: ^11.12
- illuminate/support: ^11.11
- nesbot/carbon: ^3.5
Requires (Dev)
- blumilksoftware/codestyle: ^3.2
- phpunit/phpunit: ^11.2
This package is auto-updated.
Last update: 2025-01-22 12:26:35 UTC
README
About
blumilksoftware\laravel-heatmap is an extension of blumilksoftware\heatmap allowing you to use heatmap with Model data from Laravel Eloquent.
Installation
The Laravel Heatmap is distributed as Composer library via Packagist. To add it to your project, just run:
composer require blumilksoftware/laravel-heatmap
Usage
Creating a heatmap from Laravel Collection
You can build a heatmap directly from collection of Eloquent models:
use Blumilk\LaravelHeatmap\LaravelHeatmapBuilder; use App\Models\YourModel; $data = YourModel::all(); // Assuming YourModel has a 'created_at' field $heatmapBuilder = new LaravelHeatmapBuilder(); $heatmap = $heatmapBuilder->buildFromCollection($data, 'created_at');
You can also build heatmap from array:
use Blumilk\LaravelHeatmap\LaravelHeatmapBuilder; $data = [ ["created_at" => "2022-11-01 00:00:00"], ["created_at" => "2022-11-03 00:00:00"], ["created_at" => "2022-11-16 00:00:00"], ["created_at" => "2022-11-16 00:00:00"], ["created_at" => "2022-11-18 00:00:00"], ["created_at" => "2022-11-19 00:00:00"], ]; $heatmapBuilder = new LaravelHeatmapBuilder(); $heatmap = $heatmapBuilder->buildFromArray($data, 'created_at');
There is also option to build from query:
use Blumilk\LaravelHeatmap\LaravelHeatmapBuilder; $query = YourModel::where('created_at', '>', '2022-11-01 00:00:00'); $heatmapBuilder = new LaravelHeatmapBuilder(); $heatmap = $heatmapBuilder->buildFromQuery($query, 'created_at');