In this lesson, we will create three resources for the types of beds, rooms, and apartments. All these resources will be in one group Facilities
and will only have one field name
. Should be an easy one!
So, first, let's create these resources.
php artisan make:filament-resource ApartmentTypephp artisan make:filament-resource BedTypephp artisan make:filament-resource RoomType
In all of them, let's add to a navigation group, a form, and a table.
app/Filament/Resources/ApartmentTypeResource.php:
class ApartmentTypeResource extends Resource{ protected static ?string $model = ApartmentType::class; protected static ?string $navigationIcon = 'heroicon-o-collection'; protected static ?string $navigationGroup = 'Facilities'; public static function form(Form $form): Form { return $form ->schema([ Forms\Components\TextInput::make('name') ->required(), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('name'), ]) ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\DeleteBulkAction::make(), ]); } // ...}
app/Filament/Resources/BedTypeResource.php:
class BedTypeResource extends Resource{ protected static ?string $model = BedType::class; protected static ?string $navigationIcon = 'heroicon-o-collection'; protected static ?string $navigationGroup = 'Facilities'; public static function form(Form $form): Form { return $form ->schema([ Forms\Components\TextInput::make('name') ->required(), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('name'), ]) ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\DeleteBulkAction::make(), ]); } // ...}
app/Filament/Resources/RoomTypeResource.php:
class RoomTypeResource extends Resource{ protected static ?string $model = RoomType::class; protected static ?string $navigationIcon = 'heroicon-o-collection'; protected static ?string $navigationGroup = 'Facilities'; public static function form(Form $form): Form { return $form ->schema([ Forms\Components\TextInput::make('name') ->required(), ]); } public static function table(Table $table): Table { return $table ->columns([ Tables\Columns\TextColumn::make('name'), ]) ->filters([ // ]) ->actions([ Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\DeleteBulkAction::make(), ]); } // ...}
At the end we have result like the one below.