where( 'code', $code ); } public function customerCoupon() { return $this->hasMany( related: CustomerCoupon::class, foreignKey: 'coupon_id', localKey: 'id' ); } public function categories() { return $this->hasMany( CouponCategory::class ); } public function products() { return $this->hasMany( CouponProduct::class ); } public function customers() { return $this->hasMany( related: CouponCustomer::class, foreignKey: 'coupon_id', localKey: 'id' ); } public function groups() { return $this->hasMany( related: CouponCustomerGroup::class, foreignKey: 'coupon_id', localKey: 'id' ); } public function user() { return $this->belongsTo( User::class, 'author_id' ); } }