soved / laravel-ecologi
Help restore the planet using the Ecologi API
v1.1.0
2022-02-10 07:32 UTC
Requires
- php: ^8.0
- guzzlehttp/guzzle: ^7.0.1
- illuminate/http: ^8.0|^9.0
- illuminate/queue: ^8.0|^9.0
- illuminate/support: ^8.0|^9.0
Requires (Dev)
- fakerphp/faker: ^1.9.1
- orchestra/testbench: ^6.0
This package is auto-updated.
Last update: 2024-11-10 13:55:09 UTC
README
Requirements
- PHP >= 8.0
- Laravel >= 8.0
Installation
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
Configuration
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
Usage
Track your impact
<?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
🌳 Purchase trees or carbon offset
<?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(); }
Security Vulnerabilities
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.