PHP code example of aedart / athenaeum-http-api

1. Go to this page and download the library: Download aedart/athenaeum-http-api 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/ */

    

aedart / athenaeum-http-api example snippets


use Aedart\Http\Api\Resources\ApiResource;
use Illuminate\Http\Request;

class UserResource extends ApiResource
{
    public function formatPayload(Request $request): array
    {
        return $this->withTimestamps([
            'id' => $this->getResourceKey(),
            'name' => $this->name,
            'roles' => $this->belongsToManyReference('roles')
                ->withLabel('name')
                ->withSelfLink()
                ->withResourceType();
        ]);
    }

    public function type(): string
    {
        return 'user';
    }
}