Filament x Volt relationships
Hey 👋
I’m using Wave Dojo (Volt + Filament) — docs link.
Everything works great, but I’m struggling with relationships in forms/tables.
Example: I have a
In my form, I’m trying to show them in a repeater, but it’s always empty:
Where/how should I resolve relationships so the repeater (and tables) get data from related models?
flow
table with many flow_steps
:
public function steps()
{
return $this->hasMany(FlowStep::class)->orderBy('scheduled_at');
}
public function steps()
{
return $this->hasMany(FlowStep::class)->orderBy('scheduled_at');
}
Repeater::make('steps')->schema([])
Repeater::make('steps')->schema([])
2 Replies
Here’s the full code for context:
use function Laravel\Folio\{middleware, name};
middleware(['auth', 'can:view,flow']);
name('flow.edit');
new class extends Component implements HasForms, HasTable {
use InteractsWithForms, InteractsWithTable;
public ?array $data = [];
public Flow $flow;
public function mount(): void
{
$this->form->fill($this->flow->toArray());
}
public function save()
{
Notification::make()
->title('Contact updated successfully')
->success()
->send();
}
public function table(Table $table): Table
{
return $table
->query(Flow::query()->where('id', $this->flow->id))
->columns([]);
}
public function form(Form $form): Form
{
return $form
->components([
Section::make('Step')
->schema([
\Filament\Forms\Components\Repeater::make('steps')
->schema([]),
])
])
->columns(1)
->statePath('data');
}
}
use function Laravel\Folio\{middleware, name};
middleware(['auth', 'can:view,flow']);
name('flow.edit');
new class extends Component implements HasForms, HasTable {
use InteractsWithForms, InteractsWithTable;
public ?array $data = [];
public Flow $flow;
public function mount(): void
{
$this->form->fill($this->flow->toArray());
}
public function save()
{
Notification::make()
->title('Contact updated successfully')
->success()
->send();
}
public function table(Table $table): Table
{
return $table
->query(Flow::query()->where('id', $this->flow->id))
->columns([]);
}
public function form(Form $form): Form
{
return $form
->components([
Section::make('Step')
->schema([
\Filament\Forms\Components\Repeater::make('steps')
->schema([]),
])
])
->columns(1)
->statePath('data');
}
}
<x-layouts.app>
@volt('flow.edit')
<x-app.container class="max-w-6xl">
<div class="mb-6">
<form wire:submit="save">
{{ $this->form }}
</form>
</div>
</x-app.container>
@endvolt
</x-layouts.app>
<x-layouts.app>
@volt('flow.edit')
<x-app.container class="max-w-6xl">
<div class="mb-6">
<form wire:submit="save">
{{ $this->form }}
</form>
</div>
</x-app.container>
@endvolt
</x-layouts.app>
namespace App\Models;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
class Flow extends Model
{
use HasFactory;
protected $guarded = [];
public const STATUS_PENDING = 'pending';
public const STATUS_ACTIVE = 'active';
public const STATUS_PAUSED = 'paused';
public const STATUS_COMPLETED = 'completed';
public function template()
{
return $this->belongsTo(FlowTemplate::class, 'flow_template_id');
}
public function lead()
{
return $this->belongsTo(Lead::class);
}
public function steps()
{
return $this->hasMany(FlowStep::class)->orderBy('scheduled_at');
}
}
namespace App\Models;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;
class Flow extends Model
{
use HasFactory;
protected $guarded = [];
public const STATUS_PENDING = 'pending';
public const STATUS_ACTIVE = 'active';
public const STATUS_PAUSED = 'paused';
public const STATUS_COMPLETED = 'completed';
public function template()
{
return $this->belongsTo(FlowTemplate::class, 'flow_template_id');
}
public function lead()
{
return $this->belongsTo(Lead::class);
}
public function steps()
{
return $this->hasMany(FlowStep::class)->orderBy('scheduled_at');
}
}
I think you need to add the
$record
property to the component and fill it with your current record.