10.April 2026

This commit is contained in:
Kevin Adametz 2026-04-10 17:15:27 +02:00
parent a00c42e770
commit f58c709945
208 changed files with 19280 additions and 2914 deletions

View file

@ -2,6 +2,7 @@
namespace App\Models;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
@ -339,6 +340,36 @@ class ShoppingOrder extends Model
return $this->hasMany('App\Models\ShoppingOrderItem', 'shopping_order_id');
}
/**
* Bezahlte Berater-Registrierung (payment_for = 1) mit mindestens einem Produkt, das keine
* reine Mitgliedschaft ohne Starterpaket ist ({@see Product::$is_membership_only}).
*/
public function scopeWherePaidRegistrationIncludesStarterKit(Builder $query): Builder
{
return $query
->where('payment_for', 1)
->where(function (Builder $q) {
$q->where('paid', true)
->orWhereIn('txaction', ['paid', 'extern_paid']);
})
->whereHas('shopping_order_items', function (Builder $q) {
$q->whereHas('product', function (Builder $p) {
$p->where('is_membership_only', false);
});
});
}
/**
* Erfüllt diese Bestellung die Voraussetzung für Incentive-Neupartner-Tracking (Starterpaket)?
*/
public function qualifiesForIncentiveTrackedPartner(): bool
{
return static::query()
->whereKey($this->getKey())
->wherePaidRegistrationIncludesStarterKit()
->exists();
}
public function shopping_payments()
{
return $this->hasMany('App\Models\ShoppingPayment', 'shopping_order_id');