a-lawrence/laravel-wonde

This is a bridge package for the Wonde API Client.

0.4 2017-10-11 18:21 UTC

This package is auto-updated.

Last update: 2024-12-17 20:34:21 UTC


README

This is a simple bridge for the Wonde LTD API, using Graham Campbell's Laravel Manager package as a framework.

Installation

Add this package to your composer.json file:

composer require a-lawrence/laravel-wonde

Depending on your version of Laravel, it may be necessary to add your Service Provider to your config/app.php file:

  ...
  ALawrence\LaravelWonde\WondeServiceProvider::class,
  ...
  

Along with the Alias:

  ...
  'Wonde' => ALawrence\LaravelWonde\Facades\Wonde::class,
  ...
  

Config

Within your .env file (or environment variables) you can define the following two elements:

WONDE_TOKEN=Your-Access-Token
WONDE_SCHOOL=Specific-School

You will only need to set WONDE_SCHOOL if your application is a single school application.

If you'd like more control over the configuration, you could always publish the config file for this package and modify as necessary:

php artisan vendor:publish --provider="ALawrence\LaravelWonde\WondeServiceProvider"

Usage

Basic usage can be carried out by utilising dependency injection within your controller:

class DemoController extends Controller
{
    protected $wonde;

    public function __construct(WondeManager $wonde)
    {
        $this->wonde = $wonde;
    }

    public function display()
    {
        foreach ($this->wonde->schools->all() as $school) {
            // Display school name
            echo $school->name . PHP_EOL;
        }
    }
}

If you'd prefer to not use dependency injection, then that's fine too:

public function display()
    {
        foreach (Wonde::connection("main")->schools->all() as $school) {
            // Display school name
            echo $school->name . PHP_EOL;
        }
    }

For all other usage, non-specific to this bridge, view the Wonde API Client documentation: https://github.com/wondeltd/php-client