1. Go to this page and download the library: Download vusys/laravel-bitemporal 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/ */
use Vusys\Bitemporal\Concerns\HasBitemporalRelations;
use Vusys\Bitemporal\Relations\BitemporalMany;
class Product extends Model
{
use HasBitemporalRelations;
public function prices(): BitemporalMany
{
return $this->bitemporalMany(ProductPrice::class);
}
}
use Vusys\Bitemporal\Bitemporal;
class ProductPrice extends Model
{
use Bitemporal;
protected string $temporalEntity = Product::class;
}
$price = $product->prices()
->validAt($invoice->issued_at) // true on this business date
->knownAt($invoice->created_at) // as we believed it then
->sole();