PHP code example of timothepearce / laravel-time-series
1. Go to this page and download the library: Download timothepearce/laravel-time-series 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/ */
timothepearce / laravel-time-series example snippets
use App\Models\Projections\MyProjection;
use TimothePearce\TimeSeries\Projectable;
class MyProjectableModel extends Model
{
use Projectable;
protected array $projections = [
MyProjection::class,
];
}
use App\Models\Projections\MyProjection;
use TimothePearce\TimeSeries\Projectable;
class MyProjectableModel extends Model
{
use Projectable;
protected $casts = [
'other_date_time' => 'datetime:Y-m-d H:00',
];
protected array $projections = [
MyProjection::class,
];
}
namespace App\Models\Projections;
use Illuminate\Database\Eloquent\Model;
use TimothePearce\TimeSeries\Contracts\ProjectionContract;
use TimothePearce\TimeSeries\Models\Projection;
class MyProjection extends Projection implements ProjectionContract
{
/**
* The projected periods.
*/
public array $periods = [];
public string $dateColumn = 'other_date_time';
....
MyProjection::period('1 day')
->between(
today()->subDay(), // start date
today(), // end date
)
->get();