我的模型看起来像下面的Product
模型代码:
public class Product extends Model
{
public function types()
{
return $this->belongsToMany(Type::class)
->withPivot('published');
}
}
这里是Types
模型:
public class Type extends Model
{
public function products()
{
return $this->belongsToMany(Product::class)
->withPivot('published');
}
}
在 novaProjectResource
我有以下字段:
BelongsToMany::make('Types')
->fields(function() {
return [
Boolean::make('Published')
];
})->actions(function() { return new Action/UpdateProductTypeActions }),
在 novaTypeResource
我有以下字段:
BelongsToMany::make('Projects')
->fields(function() {
return [
Boolean::make('Published')
];
}),
我想让published
数据透视表中的这个属性可以使用Nova Actions
我已经创建UpdateProductTypeActions
了如下代码:
public function handle(ActionFields $fields, Collection $models)
{
foreach ($models as $model) {
}
}
我的问题如何product_id
从这些行动中得到?