PHP code example of betalabs / laravel-api-handler

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

    

betalabs / laravel-api-handler example snippets


use Marcelgwerder\ApiHandler\Facades\ApiHandler;

/**
 * @Relation
 */
public function author() {
    return $this->belongsTo('Author');  
}

ApiHandler::parseSingle($books, array('id_origin' => 'Random Bookstore Ltd', 'id' => 1337));

ApiHandler::parseSingle($book, 1);

ApiHandler::parseMultiple($book, array('title', 'isbn', 'description'));

ApiHandler::parseSingle($books, 42)->cleanup(true)->getResponse();

/**
 * @Relation
 */
public function author() {
    return $this->belongsTo('Author');  
}

/api/books?title-lk=The Lord*&created_at-min=2014-03-14 12:55:02

/api/books?id=5|6

/api/books?id-not=5|6

/api/books?_limit=50

/api/books?_offset=20&_limit=50

/api/books?_with=author

/api/books?id-gt=5&_config=meta-total-count,meta-filter-count