statview/filament-record-finder

Record finder form component for Filament

1.0.1 2024-12-19 15:39 UTC

This package is auto-updated.

Last update: 2024-12-19 15:40:34 UTC


README

Installation

composer require statview/filament-record-finder

Create record finder classes

use App\Models\User;
use Filament\Tables\Columns;
use Filament\Tables\Table;
use Statview\FilamentRecordFinder\RecordFinder;

class RecordFinderDemo extends RecordFinder
{
    public function table(Table $table)
    {
        return $table
            ->query(
                fn () => User::query()
                    ->whereNotIn('id', $this->existingRecord)
            )
            ->columns([
                Columns\TextColumn::make('name')
                    ->searchable()
                    ->sortable(),
            ]);
    }
}

Usage

use Filament\Tables\Columns\TextColumn;
use Statview\FilamentRecordFinder\Forms\RecordFinder;

RecordFinder::make('pages')
    ->label('Subpages')
    ->relation('pages', 'title')
    ->grid()
    ->recordFinder(RecordFinderDemo::class),