PHP code example of jk-oster / laravel-collection-trend
1. Go to this page and download the library: Download jk-oster/laravel-collection-trend library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jk-oster / laravel-collection-trend example snippets
// Totals per month
$trend = CollectionTrend::make($collectable)
->between(
start: now()->startOfYear(),
end: now()->endOfYear(),
)
->perMonth()
->count();
// Average user weight where name starts with a over a span of 11 years, results are grouped per year
$trend = CollectionTrend::make($collectable)
->between(
start: now()->startOfYear()->subYears(10),
end: now()->endOfYear(),
)
->perYear()
->average('weight');