PHP code example of naturalgroove / laravel-filament-image-generator-field

1. Go to this page and download the library: Download naturalgroove/laravel-filament-image-generator-field 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/ */

    

naturalgroove / laravel-filament-image-generator-field example snippets


use \NaturalGroove\Filament\ImageGeneratorField\Forms\Components\ImageGenerator;

[...]
public static function form(Form $form): Form
{
    return $form
        ->schema([
            ImageGenerator::make('photo'),
        ]);

use \NaturalGroove\Filament\ImageGeneratorField\Forms\Components\ImageGenerator;

ImageGenerator::make('photo')
    ->imageEditor()
    ->disk('private'),

ImageGenerator::make('photo'
    ->imageGenerator('openai-dall-e-3'),

ImageGenerator::make('photo')
    ->openaiDallE2(); // equivalent to ->imageGenerator('openai-dall-e-2')

ImageGenerator::make('photo')
    ->openaiDallE3(); // equivalent to ->imageGenerator('openai-dall-e-3')

use NaturalGroove\Filament\ImageGeneratorField\Contracts\AIImageGenerator;

class MyCustomImageGenerator implements AIImageGenerator
{
    public function generate(string $prompt, int $n = 1, array $params = []): array
    {
        // your implementation
        
        return [
            [
                'url' => 'https://example.com/image.jpg'
            ]
            [...]
        ];
    }

}
bash
OPEN_AI_DALL_E_API_KEY=your-api-key
bash
php artisan vendor:publish --tag="laravel-filament-image-generator-field-config"
bash
php artisan vendor:publish --tag="laravel-filament-image-generator-field-views"