Buyer Model
Buyer Model:
The Buyer model represents authenticated buyers in the system. It manages authentication, access control, product purchases, orders, and returns
Relationships:
- **Products:**A buyer can be associated with multiple products.
public function products()
{
return $this->belongsToMany(Product::class, 'buyer_shop_product', 'buyer_id', 'shop_product_id')->withTimestamps()->withPivot('change_description', 'change_description_ar', 'my_price', 'change_name', 'change_name_ar', 'sync_product_id');
} - **Orders:**A buyer can have multiple orders
public function orders()
{
return $this->hasMany(Order::class, 'buyer_id');
} - **Returns:**A buyer can have multiple return requests
public function returns()
{
return $this->hasMany(Returns::class, 'buyer_id');
} - Customers: A buyer can be linked to multiple customers
public function customers()
{
return $this->hasMany(Customer::class, 'buyer_id', 'id');
} - **Access Control:**The Buyer model can access specific panels in the system
public function canAccessPanel(Panel $panel): bool
{
return $panel->getId() === 'buyer';
} - **Activity Logging:**The model logs activities using the Spatie Activity Log package
public function getActivitylogOptions(): LogOptions
{
return LogOptions::defaults();
}