Skip to main content

Comment Model

Definition and Role:

The Comment model is responsible for managing user-generated comments within the system. It supports polymorphic relationships, allowing comments to be associated with different models dynamically

Relationships:

  • **Customer:**Each comment is associated with a customer who made the comment
    public function customer(): BelongsTo
    {
    return $this->belongsTo(Customer::class);
    }


  • **Commentable (Polymorphic Relationship):**A comment can belong to multiple types of models dynamically using a polymorphic relationship
    public function commentable(): MorphTo
    {
    return $this->morphTo();
    }

  • Activity Logging:The model logs activities using the Spatie Activity Log package.
    public function getActivitylogOptions(): LogOptions
    {
    return LogOptions::defaults();
    }