PHP code example of soved / laravel-ecologi

1. Go to this page and download the library: Download soved/laravel-ecologi 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/ */

    

soved / laravel-ecologi example snippets




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




use Soved\Laravel\Ecologi\Contracts\EcologiContract;

$ecologi = $this->app->make(EcologiContract::class);

$ecologi->purchaseTrees(5);

$ecologi->purchaseCarbonOffset(1, 'Tonnes');




// App\Console\Kernel:

use Illuminate\Console\Scheduling\Schedule;
use Soved\Laravel\Ecologi\Jobs\PurchaseATree;

protected function schedule(Schedule $schedule)
{
    $schedule->job(new PurchaseATree)->daily();
}

bash
$ php artisan vendor:publish --tag=ecologi-config