PHP code example of tomatophp / filament-api

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

    

tomatophp / filament-api example snippets


->plugin(\TomatoPHP\FilamentApi\FilamentAPIPlugin::make())

use Filament\Resources\Pages\ListRecords;
use TomatoPHP\FilamentApi\Traits\InteractWithAPI;

class ListPosts extends ListRecords
{
    use InteractWithAPI;
}

// Return a JSON resource from the list, show, store and update endpoints
public static function getFilamentAPIResource(): ?string
{
    return PostResource::class;
}

// The middleware of the endpoints
public static function getFilamentAPIMiddleware(): array
{
    return ['auth:sanctum'];
}

// The endpoint slug, defaults to the resource slug
public static function getFilamentAPISlug(): ?string
{
    return 'articles';
}

// The form used to validate and save the store and update endpoints
public static function getFilamentAPIForm(Schema $schema): Schema
{
    return static::getResource()::form($schema);
}

// The table used to shape the list endpoint
public static function getFilamentAPITable(Table $table): Table
{
    return static::getResource()::table($table);
}
bash
php artisan vendor:publish --tag="filament-api-config"