I have model looks like this folowing Product
model code:
public class Product extends Model
{
public function types()
{
return $this->belongsToMany(Type::class)
->withPivot('published');
}
}
and here the Types
model:
public class Type extends Model
{
public function products()
{
return $this->belongsToMany(Product::class)
->withPivot('published');
}
}
in nova ProjectResource
I have this following field :
BelongsToMany::make('Types')
->fields(function() {
return [
Boolean::make('Published')
];
})->actions(function() { return new Action/UpdateProductTypeActions }),
in nova TypeResource
I have this following field :
BelongsToMany::make('Projects')
->fields(function() {
return [
Boolean::make('Published')
];
}),
and I wanna make this published
attribute from pivot table updateable using Nova Actions
and I already create UpdateProductTypeActions
like this following code:
public function handle(ActionFields $fields, Collection $models)
{
foreach ($models as $model) {
}
}
my questions how to get product_id
from those actions?