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
37
database/factories/BoostFactory.php
Normal file
37
database/factories/BoostFactory.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\Boost;
|
||||
use App\Models\PressRelease;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<Boost>
|
||||
*/
|
||||
class BoostFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'press_release_id' => PressRelease::factory(),
|
||||
'user_id' => User::factory(),
|
||||
'days' => 7,
|
||||
'credits_charged' => 12,
|
||||
'starts_at' => now(),
|
||||
'ends_at' => now()->addDays(7),
|
||||
];
|
||||
}
|
||||
|
||||
public function expired(): static
|
||||
{
|
||||
return $this->state(fn (): array => [
|
||||
'starts_at' => now()->subDays(14),
|
||||
'ends_at' => now()->subDay(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Boost (Platzierung) laut Decision-Update §2.2: bezahlte Hervorhebung einer
|
||||
* veröffentlichten, grünen PM auf Startseite UND Branchenseite. Eine Stufe –
|
||||
* nur die Laufzeit variiert (7/14/30 Tage). Mehrfachkauf verlängert (neuer
|
||||
* Zeitraum schließt an das laufende Ende an). „Aktuell geboostet" = es gibt
|
||||
* eine Zeile mit `ends_at` in der Zukunft.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('boosts', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('press_release_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedSmallInteger('days');
|
||||
$table->integer('credits_charged');
|
||||
$table->timestamp('starts_at');
|
||||
$table->timestamp('ends_at');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['press_release_id', 'ends_at']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('boosts');
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue