Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes enabled channel relation manager #1626

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Lunar\Admin\Support\RelationManagers;

use Filament;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
Expand Down Expand Up @@ -32,7 +31,7 @@ protected static function getFormInputs(): array
return [
Filament\Forms\Components\Toggle::make('enabled')->label(
__('lunarpanel::relationmanagers.channels.form.enabled.label')
)->hint(fn (Forms\Get $get): string => match ($get('enabled')) {
)->hint(fn (bool $state): string => match ($state) {
false => __('lunarpanel::relationmanagers.channels.form.enabled.helper_text_false'),
true => '',
})->hintColor('danger')->live()->columnSpan(2),
Expand Down Expand Up @@ -75,12 +74,12 @@ public function table(Table $table): Table
Tables\Columns\IconColumn::make('enabled')->label(
__('lunarpanel::relationmanagers.channels.table.enabled.label')
)
->color(fn (string $state): string => match ($state) {
'1' => 'success',
'0' => 'warning',
})->icon(fn (string $state): string => match ($state) {
'0' => 'heroicon-o-x-circle',
'1' => 'heroicon-o-check-circle',
->color(fn (bool $state): string => match ($state) {
true => 'success',
false => 'warning',
})->icon(fn (bool $state): string => match ($state) {
false => 'heroicon-o-x-circle',
true => 'heroicon-o-check-circle',
}),
Tables\Columns\TextColumn::make('starts_at')->label(
__('lunarpanel::relationmanagers.channels.table.starts_at.label')
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/Models/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ class Channel extends BaseModel
use LogsActivity;
use SoftDeletes;

public $casts = [
'enabled' => 'boolean',
];

/**
* Return a new factory instance for the model.
*/
Expand Down
Loading