-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show components on component group resource
- Loading branch information
Showing
2 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
src/Filament/Resources/ComponentResource/RelationManagers/ComponentsRelationManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?php | ||
|
||
namespace Cachet\Filament\Resources\ComponentResource\RelationManagers; | ||
|
||
use Cachet\Enums\ComponentStatusEnum; | ||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
use Filament\Tables; | ||
use Filament\Tables\Table; | ||
|
||
class ComponentsRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'components'; | ||
|
||
public function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->required() | ||
->maxLength(255), | ||
Forms\Components\ToggleButtons::make('status') | ||
->inline() | ||
->columnSpanFull() | ||
->options(ComponentStatusEnum::class) | ||
->required(), | ||
Forms\Components\MarkdownEditor::make('description') | ||
->maxLength(255) | ||
->columnSpanFull(), | ||
Forms\Components\TextInput::make('link') | ||
->url() | ||
->hint(__('An optional link to the component.')), | ||
]); | ||
} | ||
|
||
public function table(Table $table): Table | ||
{ | ||
return $table | ||
->recordTitleAttribute('name') | ||
->columns([ | ||
Tables\Columns\TextColumn::make('name'), | ||
Tables\Columns\TextColumn::make('status') | ||
->badge() | ||
->sortable(), | ||
Tables\Columns\IconColumn::make('enabled') | ||
->boolean() | ||
->toggleable(isToggledHiddenByDefault: false), | ||
]) | ||
->filters([ | ||
// | ||
]) | ||
->headerActions([ | ||
Tables\Actions\CreateAction::make(), | ||
]) | ||
->actions([ | ||
Tables\Actions\EditAction::make(), | ||
Tables\Actions\DeleteAction::make(), | ||
]) | ||
->bulkActions([ | ||
Tables\Actions\BulkActionGroup::make([ | ||
Tables\Actions\DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
} |