Some projects require dynamic controls for their homepage. You might want to show/hide page sections or change the number of records seen dynamically. This example shows you how to do that.
All the management is in the HomepageSectionResource
Filament resource
app/Filament/Resources/HomepageSectionResource.php:
public static function form(Form $form): Form{ return $form ->schema([ Forms\Components\TextInput::make('name') ->required(), // ... Forms\Components\Select::make('type') ->required() ->options([ 'popular' => 'Popular Recipes', 'latest' => 'Latest Recipes', 'category' => 'Category Based', ]) ->live(), // Conditionally show category selection for category-based sections Forms\Components\Select::make('category_slug') ->label('Category') ->options(fn () => Category::pluck('name', 'slug')) ->visible(fn (Forms\Get $get) => $get('type') === 'category'), // ... Forms\Components\Toggle::make('visible') ->label('Show on Homepage') ->default(true), ]);}
Next, we will implement: