I have a users table and products table. Each user can have many products and everything goes fine with id in the products table.
What I am trying to do is to add another incremental column in relation to users.
I am trying to not only have:
user[1] could have product id [1,5,7] ❌
user[2] could have product id [2,3,4] ❌
But also:
user[1] has product another_incrematal [1,2,3,4,5, ....] ✅
user[2] has product another_incrematal [1,2,3,4,5, ....] ✅
Are there any built-in methods in laravel that could do so?
Thanks in advance.
// User
public function products()
{
return $this->hasMany(Product::class);
}
// Product
public function user()
{
return $this->belongsTo(User::class);
}