belongsTo(Product::class)->where('status', ProductStatus::ON_SALE); } public function coupon() { return $this->hasMany(Coupon::class); } public function fav() { return $this->hasOne(UserFav::class); } public function agent() { return $this->belongsTo(Agent::class); } public function category() { return $this->belongsTo(Category::class); } public function setChannelIdAttribute($value) { if (is_array($value)) { $this->attributes['channel_id'] = join(',', array_filter($value)); } } }