mivita/app/Models/IncentiveNewPartner.php
Kevin c4edbf97e4 Recruiting Challenge: Storno nimmt Neupartner raus, Rang und Auszahlung nur mit Bestaetigung
Kundenentscheid 25.09.2026:
- Storno: Ist jede bezahlte Starterpaket-Bestellung eines Neupartners
  storniert (txaction = cancelled), bekommt das Tracking cancelled_at,
  eine Storno-Logzeile nimmt die Einmalpunkte zurueck. Nachtlauf und
  Neuaufbau markieren; "Meine Berechnung" zeigt den Partner durchgestrichen
  mit "Storniert am ..., zaehlt nicht".
- Gezaehlt wird fuer alle, einen Rang bekommen nur bestaetigte Teilnehmer;
  Export und Summen nur fuer sie. Unbestaetigte sehen "Deine Praemie nach
  Bestaetigung", im Admin "Teilnahme nicht bestaetigt, keine Auszahlung".
- Datenschutz: andere Berater sehen Unbestaetigte in der Rangliste nicht
  mehr (auch nicht anonym), VIP-Konten schon, der eigene Eintrag bleibt.
- Teilnahmebedingungen Punkt 2 und 7 und Hinweistexte in de/en/es/fr.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-25 10:44:49 +00:00

75 lines
1.8 KiB
PHP

<?php
namespace App\Models;
use App\User;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
/**
* Class IncentiveNewPartner
*
* @property int $id
* @property int $participant_id
* @property int $user_id
* @property Carbon $registered_at
* @property Carbon|null $cancelled_at
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property-read IncentiveParticipant $participant
* @property-read User $user
* @property-read Collection<int, IncentivePointsLog> $pointsLogs
*
* @mixin \Eloquent
*/
class IncentiveNewPartner extends Model
{
use HasFactory;
protected $table = 'incentive_new_partners';
protected $casts = [
'participant_id' => 'int',
'user_id' => 'int',
'registered_at' => 'datetime',
'cancelled_at' => 'datetime',
];
protected $fillable = [
'participant_id',
'user_id',
'registered_at',
'cancelled_at',
];
/**
* Nur Neupartner, die zaehlen (Starterpaket-Bestellung nicht storniert).
*/
public function scopeCounting(Builder $query): Builder
{
return $query->whereNull($query->getModel()->qualifyColumn('cancelled_at'));
}
public function isCancelled(): bool
{
return $this->cancelled_at !== null;
}
public function participant()
{
return $this->belongsTo(IncentiveParticipant::class, 'participant_id');
}
public function user()
{
return $this->belongsTo(User::class);
}
public function pointsLogs()
{
return $this->hasMany(IncentivePointsLog::class, 'incentive_new_partner_id');
}
}