Skip to main content

Brand

Definition and Role: The Brand model represents a brand within the application. It is used to manage and store information related to different brands available in the system. This model is essential for categorizing products under specific brands, which helps in organizing and filtering products based on their brand.

Relationships:

  • Addresses: The Brand model has a polymorphic many-to-many relationship with the Address model. This means that a brand can have multiple addresses, and an address can be associated with multiple brands.
    /** @return MorphToMany<Address> */
    public function addresses(): MorphToMany
    {
    return $this->morphToMany(Address::class, 'addressable', 'addressables');
    }
  • Products: The Brand model has a one-to-many relationship with the Product model. This means that a brand can have multiple products associated with it.
    /** @return HasMany<Product> */
    public function products(): HasMany
    {
    return $this->hasMany(Product::class, 'shop_brand_id');
    }

Traits:

  • HasFactory: Provides factory methods for creating model instances.
  • InteractsWithMedia: Allows the model to interact with media files.
  • LogsActivity: Enables activity logging for the model.

Attributes:

  • table: Specifies the database table name associated with the model.
    protected $table = 'shop_brands';
  • casts: Defines the data types of the model's attributes.
    protected $casts = [
    'is_visible' => 'boolean',
    ];

Activity Log Options:

  • The getActivitylogOptions method returns the default logging options for the model.
    public function getActivitylogOptions(): LogOptions
    {
    return LogOptions::defaults();
    }

Table Columns

  • name
  • slug
  • website
  • description
  • position
  • is_visible
  • seo_title
  • seo_description
  • sort