Skip to content

Commit

Permalink
add cart relation to CartItem
Browse files Browse the repository at this point in the history
  • Loading branch information
milwad-dev committed Jun 4, 2024
1 parent 11e84e2 commit 0a16e2b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Models/CartItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@ public function itemable(): \Illuminate\Database\Eloquent\Relations\MorphTo
{
return $this->morphTo();
}

/**
* Relation one-to-many, Cart model.
*/
public function cart(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Cart::class, 'cart_id');
}
}

0 comments on commit 0a16e2b

Please sign in to comment.