How to Use Searchable in Laravel 10 Filament v3
Tags: laravel, php, filament, webdev
Published: 2024-05-27 14:17:32

In this section, we will see how to implement search functionality in Laravel 10 with filamentphp v3.

You can utilize the searchable feature through the **searchable()** method.
```php
use Filament\Tables\Columns\TextColumn;
 
TextColumn::make('title')
    ->searchable()
```
Additionally, we will demonstrate how to integrate the search feature into a Laravel 10 filament v3 CRUD application.
[Laravel 10 Filament v3 CRUD Operation Example](https://larainfo.com/blogs/laravel-10-filament-v3-crud-operation-example)
**Filament/Resources/BlogResource.php**
```php
<?php

namespace App\Filament\Resources;

use App\Filament\Resources\BlogResource\Pages;
use App\Filament\Resources\BlogResource\RelationManagers;
use App\Models\Blog;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
use Filament\Tables\Columns\TextColumn;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\RichEditor;
use Filament\Tables\Columns\ImageColumn;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;

class BlogResource extends Resource
{
    protected static ?string $model = Blog::class;

    protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';

    public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Section::make()
                    ->schema([
                        TextInput::make('title')->required(),
                        RichEditor::make('content')->required(),
                    ])
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('id'),
                TextColumn::make('title')->searchable(),
                TextColumn::make('content')->limit(20)->markdown()->searchable(),
            ])
            ->filters([
                //
            ])
            ->actions([
                Tables\Actions\EditAction::make(),
            ])
            ->bulkActions([
                Tables\Actions\BulkActionGroup::make([
                    Tables\Actions\DeleteBulkAction::make(),
                ]),
            ])
            ->emptyStateActions([
                Tables\Actions\CreateAction::make(),
            ]);
    }

    public static function getRelations(): array
    {
        return [
            //
        ];
    }

    public static function getPages(): array
    {
        return [
            'index' => Pages\ListBlogs::route('/'),
            'create' => Pages\CreateBlog::route('/create'),
            'edit' => Pages\EditBlog::route('/{record}/edit'),
        ];
    }
}
```
![Searchable in Filament v3](https://larainfo.com/wp-content/uploads/2024/05/rKPfurX15f85Wc44FvEhLZn64RaZ1ezBZ5LPQDZM-1024x307.png)
### See Also

⭐[Laravel 10 Filament v3 Toggle Switch Example](https://larainfo.com/blogs/laravel-10-filament-v3-toggle-switch-example/)
⭐[Laravel 10 Filament v3 CRUD Operation Example](https://larainfo.com/blogs/laravel-10-filament-v3-crud-operation-example/)
⭐[Laravel 10 Filamentphp v3 Multiple Images Example](https://larainfo.com/blogs/laravel-10-filamentphp-v3-multiple-images-example/)
⭐[How to Use DataTables in Laravel 10 Filament v3](https://larainfo.com/blogs/how-to-use-datatables-in-laravel-10-filament-v3/)