PHP code example of bensondevs / fiddy
1. Go to this page and download the library: Download bensondevs/fiddy library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bensondevs / fiddy example snippets
use Bensondevs\Fiddy\Forms\Components\FiddySelect;
use Bensondevs\Fiddy\Forms\Components\FiddySelect\Option;
FiddySelect::make('assignee')
->options([1 => 'Alice', 2 => 'Bob'])
->descriptions([1 => 'Admin', 2 => 'Editor'])
->hints([1 => '555-0100'])
->images([1 => 'https://example.com/alice.jpg'])
->circularImages();
FiddySelect::make('user_id')
->relationship('user', 'name')
->presentUsing(UserPresenter::class);
FiddySelect::make('user_id')
->relationship('user', 'name')
->presentOptionUsing(
fn (User $record) => Option::make($record->getKey())
->title($record->name)
->description($record->email)
->image($record->avatar_url)
->circularImage(),
);
FiddySelect::make('status')
->enum(Status::class);
FiddySelect::make('user_id')
->relationship('user', 'name')
->presentOptionUsing(fn (User $record) => Option::make($record->getKey())->title($record->name));
FiddySelect::make('user_id')
->relationship('user', 'name')
->presentUsing(UserPresenter::class);
FiddySelect::make('user_id')->relationship('user', 'name'); // presentable or guess
FiddySelect::make('user_id')
->relationship('user', 'name')
->presentOptionUsing(
fn (User $related) => Option::make($related->getKey())
->title($related->name)
->description($related->email),
);
Option::make($user->getKey())
->title($user->name)
->description($user->email)
->hint($user->phone)
->image($user->avatar_url)
->circularImage()
->icon(Heroicon::OutlinedUser)
->titleSuffixIcon(Heroicon::OutlinedCheck)
->disabled(fn (): bool => ! $user->is_active)
->tooltip('Inactive users cannot be assigned');
use Bensondevs\Fiddy\Forms\Components\FiddyNumericInput;
FiddyNumericInput::make('quantity');
FiddyNumericInput::make('amount')
->money(currency: 'USD')
->spellAmount(); // optional: ->spellAmount(locale: 'id')
use Bensondevs\Fiddy\Forms\Components\FiddyRepeater;
use Filament\Forms\Components\TextInput;
use Filament\Support\Icons\Heroicon;
FiddyRepeater::make('products')
->schema([
TextInput::make('title')->live(onBlur: true),
TextInput::make('slug')->live(onBlur: true),
])
->itemLabel(fn (array $state) => $state['title'] ?? null)
->itemDescription(fn (array $state) => $state['slug'] ?? null)
->itemPrefixIcon(Heroicon::OutlinedCube)
->itemSuffixIcon(fn (array $state) => Heroicon::OutlinedArrowRight)
->itemIconColor('success'); // or Closure / Filament color array
use Bensondevs\Fiddy\Infolists\Components\FiddyEntry;
use Bensondevs\Fiddy\Support\Content;
FiddyEntry::make('author')
->circularImages()
->presentUsing(AuthorPresenter::class);
FiddyEntry::make('author')
->presentContentUsing(
fn (Author $record) => Content::make()
->title($record->name)
->description($record->email),
);
use Bensondevs\Fiddy\Infolists\Components\FiddyImageEntry;
FiddyImageEntry::make('header_image')
->rounded()
->imageHeight(80);
FiddyImageEntry::make('avatar')
->circular()
->imageSize(40);
FiddyImageEntry::make('photo')
->maxImageWidth(200)
->maxImageHeight(120);
FiddyImageEntry::make('photo')
->previewable(false); // disable lightbox; ->url() also wins over preview
use Bensondevs\Fiddy\Infolists\Components\FiddyTimestampEntry;
use Illuminate\Database\Eloquent\Model;
FiddyTimestampEntry::make('created_at')
->describeSubject()
->getSubjectUsing(fn (Model $record) => $record->creator)
->subjectPhoto()
->describeDiffForHuman();
use Bensondevs\Fiddy\Tables\Columns\FiddyColumn;
use Bensondevs\Fiddy\Support\Content;
FiddyColumn::make('author')
->circularImages()
->searchable()
->sortable()
->filterable()
->presentUsing(AuthorPresenter::class);
FiddyColumn::make('author')
->presentContentUsing(
fn (Author $related) => Content::make()
->title($related->name, attribute: 'name')
->description($related->email, attribute: 'email')
->image($related->avatar_url),
);
FiddyColumn::make('author')
->relatedRecord(fn (Post $record): ?Author => $record->coAuthor);
FiddyColumn::make('author')->presentUsing(AuthorPresenter::class);
FiddyColumn::make('author')->presentContentUsing(
function (Author $related): Content {
return Content::make()
->title($related->name, 'name')
->description($related->email, 'email')
->hint($related->phone)
->image($related->avatar_url)
->circularImage();
},
);
FiddyColumn::make('author')->presentContentUsing(
fn (Author $related): Content => Content::make()
->title($related->name)
->description($related->email),
);
FiddyColumn::make('author')
->circularImages()
->searchable()
->sortable()
->filterable();
Content::make()
->aboveTitle('Edited by Alice')
->aboveDescription('2 hours ago')
->title('Mar 1, 2026 3:00 PM')
->description('Alice')
->hint('Admin');
Content::make()
->title('Alice')
->image('https://example.com/alice.jpg')
->suffixImage('https://example.com/badge.png')
->circularImage()
->maxImageWidth(40)
->imageHeight(40);
use Filament\Support\Icons\Heroicon;
Content::make()
->aboveTitle('Edited by Alice')
->aboveTitlePrefixIcon(Heroicon::OutlinedPencil)
->title('Mar 1, 2026 3:00 PM')
->titlePrefixIcon(Heroicon::OutlinedClock)
->description('Alice')
->descriptionPrefixIcon(Heroicon::OutlinedUser)
->hint('Admin')
->hintPrefixIcon(Heroicon::OutlinedShieldCheck)
->icon(Heroicon::OutlinedUser);
use Bensondevs\Fiddy\Tables\Columns\FiddyTimestampColumn;
use Filament\Support\Icons\Heroicon;
use Illuminate\Database\Eloquent\Model;
FiddyTimestampColumn::make('created_at')
->describeSubject()
->getSubjectUsing(fn (Model $record) => $record->creator)
->subjectPhoto()
->describeDiffForHuman()
->titlePrefixIcon(Heroicon::OutlinedClock);
FiddyTimestampColumn::make('updated_at')
->describeSubject('top')
->describeDiffForHuman('bottom')
->getSubjectUsing(fn (Order $record): ?User => $record->editor)
->getSubjectNameUsing(fn (User $subject): string => $subject->display_name)
->subjectPhoto()
->getSubjectPhotoUsing(fn (User $subject): ?string => $subject->avatar_url);
FiddyTimestampColumn::make('updated_at')
->describeSubject('top')
->describeDiffForHuman('bottom')
->getSubjectUsing(fn (Order $record): ?User => $record->editor)
->getSubjectNameUsing(fn (User $subject): string => $subject->display_name)
->subjectPhoto(fn (): bool => true)
->getSubjectPhotoUsing(fn (User $subject): ?string => $subject->avatar_url)
->titlePrefixIcon(Heroicon::OutlinedClock)
->descriptionPrefixIcon(Heroicon::OutlinedUser);
use Bensondevs\Fiddy\Tables\Filters\FiddySelectFilter;
use Bensondevs\Fiddy\Forms\Components\FiddySelect\Option;
FiddySelectFilter::make('author_id')
->relationship('author', 'name')
->presentUsing(AuthorPresenter::class)
->searchable()
->preload();
FiddySelectFilter::make('status')
->enum(Status::class);
use Bensondevs\Fiddy\Tables\Filters\Indicator;
use Filament\Support\Icons\Heroicon;
// Typically returned from asFilterIndicator() on a presentable model:
return Indicator::make($this->name)
->prefixIcon(Heroicon::OutlinedUser);
use Bensondevs\Fiddy\Models\Contracts\FiddyComponentsPresentable;
use Bensondevs\Fiddy\Forms\Components\FiddySelect\Option;
use Bensondevs\Fiddy\Support\Content;
use Bensondevs\Fiddy\Tables\Filters\Indicator;
class Author implements FiddyComponentsPresentable
{
public function asOption(): Option { /* select / filter options */ }
public function asColumnContent(): Content { /* table cell */ }
public function asEntryContent(): Content { /* infolist entry */ }
public function asFilterIndicator(): Indicator
{
return Indicator::make($this->name);
}
}
FiddySelect::make('author_id')->relationship('author', 'name');
FiddyColumn::make('author');
FiddyEntry::make('author');
FiddySelectFilter::make('author_id')->relationship('author', 'name');
FiddySelect::make('user_id')->relationship('user', 'name');
FiddyColumn::make('user');
use Bensondevs\Fiddy\Support\Presenter;
use Bensondevs\Fiddy\Forms\Components\FiddySelect\Option;
use Bensondevs\Fiddy\Support\Content;
final class UserPresenter extends Presenter
{
public function toOption(): Option
{
return Option::make($this->record->getKey())
->title($this->record->name)
->description($this->record->email);
}
public function toContent(): Content
{
return Content::make()
->title($this->record->name)
->description($this->record->email);
}
}
use Bensondevs\Fiddy\Models\Concerns\HasFiddyPresenter;
use Bensondevs\Fiddy\Models\Contracts\FiddyComponentsPresentable;
class User extends Model implements FiddyComponentsPresentable
{
use HasFiddyPresenter;
protected static string $fiddyPresenter = UserPresenter::class;
}
FiddySelect::make('user_id')->relationship('user', 'name');
FiddyColumn::make('user');
FiddyEntry::make('user');
FiddySelectFilter::make('user_id')->relationship('user', 'name');
FiddySelect::make('user_id')->relationship('user', 'name')->presentUsing(UserPresenter::class);
FiddyColumn::make('user')->presentUsing(UserPresenter::class);
FiddyEntry::make('user')->presentUsing(UserPresenter::class);
FiddySelectFilter::make('user_id')->relationship('user', 'name')->presentUsing(UserPresenter::class);
bash
php artisan fiddy:presenter User