Neue JSON-Spalte plans.benefits (Migration + Cast + Plan::benefitsList()). Im Admin (Tarife & Pakete) pro Tarif zeilenweise pflegbar; die In-App- Buchungsseite rendert die Liste in den Tarif-Karten statt einer festen Zeile. Seeder/Factory mit Beispiel-Vorteilen. Single Source of Truth fuer Buchungsseite und (folgt separat) die oeffentliche Preise-Seite. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
68 lines
1.8 KiB
PHP
68 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
/**
|
|
* Tarif-Katalog laut Decision-Update (Starter/Business/Pro/Agency).
|
|
*
|
|
* Der Jahrespreis entspricht 10 Monatsbeiträgen und wird als
|
|
* „2 Monate gratis" kommuniziert. `press_release_quota` ist das
|
|
* monatliche PM-Kontingent, `daily_limit` der Flut-Schutz (null = ohne).
|
|
*/
|
|
class Plan extends Model
|
|
{
|
|
use HasFactory;
|
|
|
|
protected $fillable = [
|
|
'slug',
|
|
'name',
|
|
'monthly_price_cents',
|
|
'yearly_price_cents',
|
|
'currency',
|
|
'press_release_quota',
|
|
'daily_limit',
|
|
'stripe_product_id',
|
|
'stripe_price_id_monthly',
|
|
'stripe_price_id_yearly',
|
|
'is_active',
|
|
'sort_order',
|
|
'benefits',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'monthly_price_cents' => 'integer',
|
|
'yearly_price_cents' => 'integer',
|
|
'press_release_quota' => 'integer',
|
|
'daily_limit' => 'integer',
|
|
'is_active' => 'boolean',
|
|
'sort_order' => 'integer',
|
|
'benefits' => 'array',
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Gepflegte Vorteilsliste als bereinigtes String-Array (leere Zeilen
|
|
* entfernt). Single Source of Truth für Buchungsseite und Preise-Seite.
|
|
*
|
|
* @return list<string>
|
|
*/
|
|
public function benefitsList(): array
|
|
{
|
|
return collect($this->benefits ?? [])
|
|
->map(fn ($benefit): string => trim((string) $benefit))
|
|
->filter()
|
|
->values()
|
|
->all();
|
|
}
|
|
|
|
public function scopeActive(Builder $query): Builder
|
|
{
|
|
return $query->where('is_active', true)->orderBy('sort_order');
|
|
}
|
|
}
|