Logo

dev-resources.site

for different kinds of informations.

How to Use Searchable in Laravel 10 Filament v3

Published at
5/27/2024
Categories
laravel
php
filament
webdev
Author
saim_ansari
Categories
4 categories in total
laravel
open
php
open
filament
open
webdev
open
Author
11 person written this
saim_ansari
open
How to Use Searchable in Laravel 10 Filament v3

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.

use Filament\Tables\Columns\TextColumn;

TextColumn::make('title')
    ->searchable()
Enter fullscreen mode Exit fullscreen mode

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
Filament/Resources/BlogResource.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'),
        ];
    }
}
Enter fullscreen mode Exit fullscreen mode

Searchable in Filament v3

See Also

ā­Laravel 10 Filament v3 Toggle Switch Example
ā­Laravel 10 Filament v3 CRUD Operation Example
ā­Laravel 10 Filamentphp v3 Multiple Images Example
ā­How to Use DataTables in Laravel 10 Filament v3

filament Article's
30 articles in total
Favicon
Multi select default selection i filament v3
Favicon
Filament: Image Color Picker component
Favicon
My First No-Code SaaS Took off - $8K in 40 days
Favicon
Add a sidebar with options in a Filament resource
Favicon
Filament: Modify login or logout response
Favicon
Filament Database Notification Sound
Favicon
Laravel Nova vs Filament: The Best Admin Panels
Favicon
Filament: Add icon to form buttons
Favicon
Filament Breezy: add new field to Personal Info component
Favicon
Filament: Delete Attachments when Deleting a Record
Favicon
Filament: Generate Resource from Existing DB Schema
Favicon
Filament Breezy: set storage disk for avatar
Favicon
Laravel Stats : Filament Charts.js pour faire les statistiques
Favicon
Filament How to redirect to list page after (create,update) using Trait
Favicon
How to solve Symfony\Component\Routing\Exception\RouteNotFoundException Route [filament.admin.resources.api-keys.index] not
Favicon
Apa itu Laravel Filament?
Favicon
Laravel Filament: get resource table data by authenticated id
Favicon
Change Default Colors in FilamentPHP
Favicon
How to Use Searchable in Laravel 10 Filament v3
Favicon
Filament: add a confirmation password field in a form
Favicon
TomatoPHP Filament Plugins
Favicon
Debug Filament Search Query
Favicon
Filament PHP Blade UI Components Visually Explained
Favicon
Filament Context Menu
Favicon
How to Extend a Filament Resource
Favicon
Linkeeper - Lesson 02 - Start playing with Filament
Favicon
Linkeeper - Lesson 01 - Installation
Favicon
Filament has SPA mode!
Favicon
Access parent component value from the Repeater in Filament
Favicon
Filament v3 - Multi-tenancy form component scoping

Featured ones: