Back to School: coupon SCHOOL25 for 40% off Yearly/Lifetime membership! Read more here

Filament: Custom Page with Search in 3rd-Party Service

Filament 4
Also available in Filament 3 version

An example of using a form to search or request data from external databases or services and display the results.

01JHFNS4WT0V2WGNR40YRFK6H3

Get the Source Code:

How it works

We have a custom Filament page where we show a form.

app/Filament/Pages/AskAI.php:

use Filament\Pages\Page;
use Filament\Forms\Form;
use Filament\Forms\Components\Textarea;
 
class AskAI extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-question-mark-circle';
 
protected static string $view = 'filament.pages.ask-ai';
 
protected static ?string $title = 'Ask AI';
 
public ?array $data = [];
 
public string $answer = '';
 
public function mount(): void
{
$this->form->fill();
}
 
public function form(Form $form): Form
{
return $form
->schema([
Textarea::make('question')
->required(),
])
->statePath('data');
}
}

resources/views/filament/pages/ask-ai.blade.php:

<x-filament-panels::page>
<x-filament-panels::form wire:submit="submit">
{{ $this->form }}
 
<div>
<x-filament::button type="submit">
{{ __('Submit Question') }}
</x-filament::button>
</div>
</x-filament-panels::form>
</x-filament-panels::page>

When a form is submitted, a submit() method is called. In this method, a service is called to make an API request to OpenAI.

The FULL tutorial is available after the purchase: in the Readme file of the official repository you would get invited to.
Get the Source Code: All 151 Premium Examples for $99