Skip to content

Commit c5c747c

Browse files
committed
Show components on component group resource
1 parent 981e0a4 commit c5c747c

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

src/Filament/Resources/ComponentGroupResource.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Cachet\Enums\ComponentGroupVisibilityEnum;
66
use Cachet\Enums\ResourceVisibilityEnum;
77
use Cachet\Filament\Resources\ComponentGroupResource\Pages;
8+
use Cachet\Filament\Resources\ComponentResource\RelationManagers\ComponentsRelationManager;
89
use Cachet\Models\ComponentGroup;
910
use Filament\Forms;
1011
use Filament\Forms\Form;
@@ -79,7 +80,7 @@ public static function table(Table $table): Table
7980
public static function getRelations(): array
8081
{
8182
return [
82-
//
83+
ComponentsRelationManager::class,
8384
];
8485
}
8586

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
namespace Cachet\Filament\Resources\ComponentResource\RelationManagers;
4+
5+
use Cachet\Enums\ComponentStatusEnum;
6+
use Filament\Forms;
7+
use Filament\Forms\Form;
8+
use Filament\Resources\RelationManagers\RelationManager;
9+
use Filament\Tables;
10+
use Filament\Tables\Table;
11+
12+
class ComponentsRelationManager extends RelationManager
13+
{
14+
protected static string $relationship = 'components';
15+
16+
public function form(Form $form): Form
17+
{
18+
return $form
19+
->schema([
20+
Forms\Components\TextInput::make('name')
21+
->required()
22+
->maxLength(255),
23+
Forms\Components\ToggleButtons::make('status')
24+
->inline()
25+
->columnSpanFull()
26+
->options(ComponentStatusEnum::class)
27+
->required(),
28+
Forms\Components\MarkdownEditor::make('description')
29+
->maxLength(255)
30+
->columnSpanFull(),
31+
Forms\Components\TextInput::make('link')
32+
->url()
33+
->hint(__('An optional link to the component.')),
34+
]);
35+
}
36+
37+
public function table(Table $table): Table
38+
{
39+
return $table
40+
->recordTitleAttribute('name')
41+
->columns([
42+
Tables\Columns\TextColumn::make('name'),
43+
Tables\Columns\TextColumn::make('status')
44+
->badge()
45+
->sortable(),
46+
Tables\Columns\IconColumn::make('enabled')
47+
->boolean()
48+
->toggleable(isToggledHiddenByDefault: false),
49+
])
50+
->filters([
51+
//
52+
])
53+
->headerActions([
54+
Tables\Actions\CreateAction::make(),
55+
])
56+
->actions([
57+
Tables\Actions\EditAction::make(),
58+
Tables\Actions\DeleteAction::make(),
59+
])
60+
->bulkActions([
61+
Tables\Actions\BulkActionGroup::make([
62+
Tables\Actions\DeleteBulkAction::make(),
63+
]),
64+
]);
65+
}
66+
}

0 commit comments

Comments
 (0)