灯丝多对多关系管理器,不起作用

问题描述 投票:0回答:1

我有模范学生

学生

  • 团体:属于多个

和模特组

团体

  • 学生:有很多

当然有一个数据透视表 group_student 与

组ID 学生ID

我正在尝试在 Filament3 中设置一个 StudentRelationManager ,以便我可以使用表(而不是 select )将学生添加到组中

我运行了这个命令

php artisan make:filament-relation-manager GroupResource students student_id

当然还添加了关系

public static function getRelations(): array
    {
        return [
            RelationManagers\StudentsRelationManager::class
        ];
    }

但是在给定组记录上单击编辑的那一刻

我明白了

这是错误的,因为学生不仅仅属于一个群体,而可能属于多个群体, 所以它没有 group_id,但取决于数据透视表:group_student

而不是像这样的东西

我缺少什么?如何让它发挥作用?这可以实现吗?我搜索了,但除了用 select 修复它之外找不到其他的。

请指教

laravel laravel-livewire tail laravel-filament filamentphp
1个回答
0
投票

所以,答案是使用标志关联

 php artisan make:filament-relation-manager GroupResource students student_id --associate
© www.soinside.com 2019 - 2024. All rights reserved.