*/ protected $fillable = [ 'user_id', 'course_id' ]; /** * Get the user that owns the cart item. */ public function user(): BelongsTo { return $this->belongsTo(User::class); } /** * Get the course that belongs to the cart item. */ public function course(): BelongsTo { return $this->belongsTo(Course::class); } /** * Scope a query to only include cart items for a specific user. */ public function scopeForUser($query, $userId) { return $query->where('user_id', $userId); } }