Skip to content

Commit 232be0a

Browse files
committed
Setup relationships for orders
1 parent cabd489 commit 232be0a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

app/Models/Order.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,15 @@ class Order extends Model
1010
use HasFactory;
1111

1212
protected $guarded = [];
13+
14+
public function user()
15+
{
16+
return $this->belongsTo(User::class);
17+
}
18+
19+
public function products()
20+
{
21+
return $this->belongsToMany(Product::class)
22+
->withPivot('quantity');
23+
}
1324
}

0 commit comments

Comments
 (0)