You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Product model and a Category model. The Product model has a belongsToMany relationship with Category
/**
* App\Models\Product.
*
* @property int $id
* @property string $name
* @property string $url
* @property string $description
* @property \Illuminate\Support\Carbon|null $created_at
*/
class Product extends Model {
use RevisionableTrait;
public $guarded = ['id'];
public function categories() {
return $this->belongsToMany(Category::class, 'product_category');
}
}
/**
* App\Models\Category.
*
* @property int $id
* @property string|null $parent_category_id
* @property string $name
* @property string $description
*/
class Category extends Model {
public $guarded = ['id'];
public $timestamps = false;
}
When I save a Product I get the expected results of records inserted into the revisions table. However I'm also like to see records inserted when categories are added or removed. How would I accomplish this given that product_category doesn't have it's own model?
The text was updated successfully, but these errors were encountered:
I know from your other issue that you aren't looking into this package anymore, but if anyone else comes looking, here's a SO answer with a possible work around for this missing functionality: https://stackoverflow.com/a/37952887/10228954
I have a
Product
model and a Category model. TheProduct
model has abelongsToMany
relationship withCategory
When I save a Product I get the expected results of records inserted into the revisions table. However I'm also like to see records inserted when categories are added or removed. How would I accomplish this given that
product_category
doesn't have it's own model?The text was updated successfully, but these errors were encountered: