I have two tables products and orders which are linked by a pivot table order_product with the id of each table. But I also want to add an amout column to the pivot table. How can I do this with laravel Voyager?
Asked
Active
Viewed 287 times
1 Answers
0
Easily just define it in your migration file of order_product and access it from relation function as bellow:
Schema::create('order_product', function (Blueprint $table) {
$table->unsignedBigInteger('order_id');
$table->unsignedBigInteger('product_id');
$table->unsignedInteger('amount');
});
and for example in your product model:
public function orders()
{
return $this->belongsToMany(Order::class)
->withPivot('amount');
}

kazemm
- 473
- 5
- 19
-
I mean inside Laravel Voyager – Ahmed Ibrahim Dec 13 '21 at 10:26