Skip to main content

Address Model

Address Model:

The Address model manages addresses associated with customers and brands within the system. It supports polymorphic relationships, allowing it to be linked dynamically to different models

Relationships:

  • **Customers:**An address can be associated with multiple customers
    public function customers(): MorphToMany
    {
    return $this->morphedByMany(Customer::class, 'addressable');
    }


  • **Brands:**An address can be associated with multiple brands.
    public function brands(): MorphToMany
    {
    return $this->morphedByMany(Brand::class, 'addressable');
    }

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

Table Columns

  • id - The primary key of the addresses table.

  • table - The associated table (addresses).

  • created_at - Timestamp for record creation.

  • updated_at - Timestamp for last record update