anooserve/laravel-treenation

A Laravel package to help integrate with https://tree-nation.com/.

0.1.3 2021-04-04 12:56 UTC

This package is auto-updated.

Last update: 2024-05-07 22:55:47 UTC


README

Latest Version on Packagist pipeline status Total Downloads

Installation

You can install the package via composer:

composer require anooserve/laravel-treenation

You can publish and run the migrations with:

php artisan vendor:publish --tag="treenation-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="treenation-config"

This is the contents of the published config file. Debug defaults to on for safety:

return [
	'account_id' => env('TREENATION_ACCOUNT_ID', 'your_account_id'),
	'account_name' => env('TREENATION_ACCOUNT_NAME', 'anooserve'),
	'api_key' => env('TREENATION_API_KEY', 'your_api_key'),

	'debug' => true
];

You can publish the views with:

php artisan vendor:publish --tag="treenation-views"

Usage

Use the website CO2 offset badge:

<x-treenation::tracker />

Additionally, you can switch to the black background with the theme attribute:

<x-treenation::tracker theme="black" />

To gather data from the public Tree Nation API:

$projects = TreeNation::getProjects();
$projectDetails = TreeNation::getProjectDetails($projects[0]['id']);
$species = TreeNation::getSpecies($projects[0]['id']);

$speciesDetails = TreeNation::getSpeciesDetails($species[0]['id']);
$forestDetails = TreeNation::getForestDetails(32);

$treeCount = TreeNation::getForestTreeCount('anooserve', 'year');

To Do

  • Add REST methods that require authorisation.
  • Add PHPDoc comments to all methods

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.