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
57
app/Models/Boost.php
Normal file
57
app/Models/Boost.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Services\PressRelease\BoostService;
|
||||
use Database\Factories\BoostFactory;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
/**
|
||||
* Ein gekaufter Boost-Zeitraum. Anlage ausschließlich über
|
||||
* {@see BoostService} (Gate + Wallet-Belastung).
|
||||
*/
|
||||
class Boost extends Model
|
||||
{
|
||||
/** @use HasFactory<BoostFactory> */
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'press_release_id',
|
||||
'user_id',
|
||||
'days',
|
||||
'credits_charged',
|
||||
'starts_at',
|
||||
'ends_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'days' => 'integer',
|
||||
'credits_charged' => 'integer',
|
||||
'starts_at' => 'datetime',
|
||||
'ends_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function pressRelease(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(PressRelease::class);
|
||||
}
|
||||
|
||||
public function user(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Boosts, deren Platzierung gerade aktiv ist (läuft noch).
|
||||
*/
|
||||
public function scopeActive(Builder $query): Builder
|
||||
{
|
||||
return $query->where('ends_at', '>', now());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue