PHP code example of cloudmonitor / apiflow

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

    

cloudmonitor / apiflow example snippets


class UserController extends APIController
{
  public function index()
  {
    return parent::api(\App\Http\Resources\User::class, \App\Models\User::class)->many();
  }
}

class UserController extends APIController
{
  public function index()
  {
    return parent::api()->many();
  }
}

class UserController extends APIController
{
  public function show($id)
  {
    return parent::api()->one($id);
  }
}

class UserController extends APIController
{
  public function index()
  {
    return parent::api()
      ->apply(function(Builder $q) {
        return $q->where('id', '<', 10);
      })
      ->many();
  }
}

/**
 * Search query database columns.
 * 
 * @var array
 */
protected $queryColumns = ['name', 'email', 'auid'];

/**
 * Model scopes exposed to the API.
 * 
 * @var array
 */
protected $scopes = ['departments'];

/**
 * Related models API can 

GET /api/users?departments=1,2

public function scopeDepartments(Builder $query, array $departments): void
shell
/api/users?query=John&exclude=4&limit=10&with=department,team&departments=1,3&orderBy=name