statview/filament-record-finder

Record finder form component for Filament

1.0.0 2024-01-04 16:24 UTC

This package is auto-updated.

Last update: 2024-11-04 18:07:54 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),