Select default relationship
<?php
namespace App\Filament\User\Pages;
use App\Enums\PaymentType;
use App\Models\Store;
use Filament\Facades\Filament;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;
use Filament\Pages\Dashboard as BaseDashboard;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
class Dashboard extends BaseDashboard
{
use HasFiltersForm;
protected static ?string $navigationIcon = 'heroicon-o-home';
protected static ?string $title = 'Escritorio';
protected static string $view = 'filament-panels::pages.dashboard';
public function mount(): void
{
abort_unless(auth()->user()->hasRole('user'), 403);
}
public static function shouldRegisterNavigation(): bool
{
return auth()->user()->hasRole('user');
}
public function filtersForm(Form $form): Form
{
// dd(auth()->user()->stores()->pluck('name', 'id'));
return $form
->schema([
Select::make('stores')
->multiple()
->relationship('stores', 'name')
->searchable()
->preload()
->default([Filament::getTenant()->id])
->options(auth()->user()->stores()->pluck('name', 'id'))
->label('Tiendas'),
DatePicker::make('startDate')->default(now())->label('Desde'),
DatePicker::make('endDate')->default(now())->label('Hasta'),
Select::make('payment_method')->options(PaymentType::class)->label('Método de pago')
]);
}
}<?php
namespace App\Filament\User\Pages;
use App\Enums\PaymentType;
use App\Models\Store;
use Filament\Facades\Filament;
use Filament\Forms\Components\DatePicker;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;
use Filament\Pages\Dashboard as BaseDashboard;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
class Dashboard extends BaseDashboard
{
use HasFiltersForm;
protected static ?string $navigationIcon = 'heroicon-o-home';
protected static ?string $title = 'Escritorio';
protected static string $view = 'filament-panels::pages.dashboard';
public function mount(): void
{
abort_unless(auth()->user()->hasRole('user'), 403);
}
public static function shouldRegisterNavigation(): bool
{
return auth()->user()->hasRole('user');
}
public function filtersForm(Form $form): Form
{
// dd(auth()->user()->stores()->pluck('name', 'id'));
return $form
->schema([
Select::make('stores')
->multiple()
->relationship('stores', 'name')
->searchable()
->preload()
->default([Filament::getTenant()->id])
->options(auth()->user()->stores()->pluck('name', 'id'))
->label('Tiendas'),
DatePicker::make('startDate')->default(now())->label('Desde'),
DatePicker::make('endDate')->default(now())->label('Hasta'),
Select::make('payment_method')->options(PaymentType::class)->label('Método de pago')
]);
}
}But in no Select field it sets the default value I want, except in startDate and endDate, which do have it by default. What could be happening?