- PHP >= 8.0
- Laravel >= 8.0
First, install the package via the Composer package manager:
$ composer require soved/laravel-ecologi
After installing the package, you should publish the configuration file:
$ php artisan vendor:publish --tag=ecologi-config
Create a business or impact-only account. Obtain a API token here. Add the API token to your environment variables:
ECOLOGI_TOKEN=91757e14-3772-41a1-8020-cf434805b64e
<?php
use Soved\Laravel\Ecologi\Contracts\EcologiContract;
$ecologi = $this->app->make(EcologiContract::class);
$impact = $ecologi->getImpact('sander');
// ['trees' => 29, 'carbonOffset' => 16.883]
$treesPlanted = $ecologi->getTrees('sander');
// 29
$carbonOffset = $ecologi->getCarbonOffset('sander');
// 16.883
<?php
use Soved\Laravel\Ecologi\Contracts\EcologiContract;
$ecologi = $this->app->make(EcologiContract::class);
$ecologi->purchaseTrees(5);
$ecologi->purchaseCarbonOffset(1, 'Tonnes');
You could also schedule one of the following jobs: PurchaseATree
, PurchaseCarbonOffset(quantity: 1000, 'KG')
or PurchaseTrees(quantity: 5)
<?php
// App\Console\Kernel:
use Illuminate\Console\Scheduling\Schedule;
use Soved\Laravel\Ecologi\Jobs\PurchaseATree;
protected function schedule(Schedule $schedule)
{
$schedule->job(new PurchaseATree)->daily();
}
If you discover a security vulnerability within this project, please send an e-mail to Sander de Vos via sander@tutanota.de. All security vulnerabilities will be promptly addressed.