Boost-Geschaeftslogik (Decision-Update 2.2)
Bezahlte Platzierung gruener, veroeffentlichter PMs ueber die Credit-Wallet: - boosts Tabelle (Zeitraum starts_at/ends_at, days, credits_charged) - BoostService: Gate (nur Published + Green), Preis nach Laufzeit (7/14/30 -> 12/20/35 Credits), Mehrfachkauf verlaengert vom laufenden Ende, Wallet-Belastung referenziert den Boost im Ledger - PressRelease::boosts()/isBoosted()/scopeBoosted() als Basis fuer die Featured-Platzierung (Frontend-Anbindung bleibt der Web-Strecke ueberlassen) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
3e8844245d
commit
c7a4c8bfd4
7 changed files with 355 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ use App\Models\Concerns\HasUniqueSlug;
|
|||
use App\Scopes\PortalScope;
|
||||
use App\Services\PressRelease\PressReleaseHtmlSanitizer;
|
||||
use Database\Factories\PressReleaseFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
|
@ -167,6 +168,28 @@ class PressRelease extends Model
|
|||
return $this->hasMany(KiAudit::class)->orderByDesc('created_at');
|
||||
}
|
||||
|
||||
public function boosts(): HasMany
|
||||
{
|
||||
return $this->hasMany(Boost::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Aktuell geboostet (mindestens ein laufender Boost-Zeitraum)?
|
||||
*/
|
||||
public function isBoosted(): bool
|
||||
{
|
||||
return $this->boosts()->active()->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Beschränkt auf PMs mit aktuell laufendem Boost — Basis für die
|
||||
* Featured-Platzierung auf Start-/Branchenseite.
|
||||
*/
|
||||
public function scopeBoosted(Builder $query): Builder
|
||||
{
|
||||
return $query->whereHas('boosts', fn (Builder $q) => $q->active());
|
||||
}
|
||||
|
||||
/**
|
||||
* Display-ready text. Returns sanitized HTML for Phase-7+ PMs and
|
||||
* <p>/<br>-wrapped legacy plain text for older imports.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue