PHP code example of 99designs / relax
1. Go to this page and download the library: Download 99designs/relax 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/ */
99designs / relax example snippets
$client = new \Ergo\Http\Client("http://mywebservice.io");
$model = new Relax_Client_Model($client);
$model
->hasMany(
$model->define('Transaction')
->hasMany('PaymentDevice')
->hasMany('PaymentIntention')
->hasMany('TransactionItem','items','item')
)
->hasMany(
$model->define('Customer')
->hasOne('Address')
)
;
// GET queries
$items = $model->transactions(1)->items(); // returns a collection from /transactions/1/items
$address = $model->customers(1)->address(); // returns a resource from /customers/1/address
print $address->streetname; // returns the streetname property from the json doc
print $items->count(); // returns the number of items in the transaction
// PUT queries
$model->customers()->create(array('i'=>'x'));
// POST queries
$model->customers(1)->set('name','Fred')->save();