Incentive (E1): "Nur fuer VIP sichtbar" und Ranglisten-Seite mit Teilnahme-Block oben
Haken vip_only am Incentive: aktives Incentive erscheint dann nur fuer VIP-Konten in Sidenav, Dashboard, Teaser, Rangliste und Details, andere Berater bekommen 404; das Tracking laeuft fuer alle weiter. Seeder setzt den Haken fuer die Abstimmung der Recruiting Challenge. Ranglisten-Seite: solange die Teilnahme nicht bestaetigt ist, steht der Teilnahme-Block mit Praemien-Chips, Checkbox, Button und aufklappbaren Bedingungen ganz oben, darunter Trennlinie, Titel, Untertitel, Bild, Beschreibung und die Info-Kacheln. Ueberschriften vergroessert, Abo-Bloecke nur wenn Abos zaehlen. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
4e4b58e90e
commit
3341c929eb
18 changed files with 717 additions and 185 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Models;
|
||||
|
||||
use App\User;
|
||||
use Carbon\Carbon;
|
||||
use Cviebrock\EloquentSluggable\Sluggable;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
|
@ -37,6 +38,7 @@ use Illuminate\Database\Eloquent\SoftDeletes;
|
|||
* @property float|null $bonus_rank_3
|
||||
* @property bool $include_sales_points
|
||||
* @property int $status
|
||||
* @property bool $vip_only
|
||||
* @property Carbon|null $created_at
|
||||
* @property Carbon|null $updated_at
|
||||
* @property Carbon|null $deleted_at
|
||||
|
|
@ -70,6 +72,7 @@ class Incentive extends Model
|
|||
'bonus_rank_3' => 'float',
|
||||
'include_sales_points' => 'bool',
|
||||
'status' => 'int',
|
||||
'vip_only' => 'bool',
|
||||
'qualification_start' => 'date',
|
||||
'qualification_end' => 'date',
|
||||
'calculation_end' => 'date',
|
||||
|
|
@ -99,6 +102,7 @@ class Incentive extends Model
|
|||
'bonus_rank_3',
|
||||
'include_sales_points',
|
||||
'status',
|
||||
'vip_only',
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
@ -141,6 +145,18 @@ class Incentive extends Model
|
|||
return $query->where('status', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Incentives, die dieser Berater sehen darf: VIP sieht alles, andere nur ohne VIP-Sperre.
|
||||
*/
|
||||
public function scopeVisibleFor($query, ?User $user)
|
||||
{
|
||||
if ($user?->isVIP()) {
|
||||
return $query;
|
||||
}
|
||||
|
||||
return $query->where('vip_only', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Incentives, bei denen Umsatzpunkte der Neupartner/Neuabos mitzaehlen.
|
||||
*/
|
||||
|
|
@ -183,14 +199,23 @@ class Incentive extends Model
|
|||
*
|
||||
* @return Collection<int, Incentive>
|
||||
*/
|
||||
public static function activeForNavigation(): Collection
|
||||
public static function activeForNavigation(?User $user = null): Collection
|
||||
{
|
||||
return static::active()
|
||||
->visibleFor($user)
|
||||
->orderBy('qualification_start')
|
||||
->orderBy('id')
|
||||
->get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Darf dieser Berater das Incentive sehen (Teaser, Rangliste, Details, Teilnahme)?
|
||||
*/
|
||||
public function isVisibleFor(?User $user): bool
|
||||
{
|
||||
return ! $this->vip_only || (bool) $user?->isVIP();
|
||||
}
|
||||
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->status === 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue