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
b091dd9b1a
commit
9879e6798e
18 changed files with 717 additions and 185 deletions
|
|
@ -59,6 +59,7 @@ class IncentiveController extends Controller
|
|||
'bonus_rank_2' => 'nullable|numeric|min:0|max:999999',
|
||||
'bonus_rank_3' => 'nullable|numeric|min:0|max:999999',
|
||||
'include_sales_points' => 'nullable|boolean',
|
||||
'vip_only' => 'nullable|boolean',
|
||||
'status' => 'required|integer|in:0,1,2',
|
||||
]);
|
||||
$data = $this->normalizePayoutFields($data);
|
||||
|
|
@ -122,6 +123,7 @@ class IncentiveController extends Controller
|
|||
$data[$field] = isset($data[$field]) && $data[$field] !== '' ? round((float) $data[$field], 2) : null;
|
||||
}
|
||||
$data['include_sales_points'] = filter_var($data['include_sales_points'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
$data['vip_only'] = filter_var($data['vip_only'] ?? false, FILTER_VALIDATE_BOOLEAN);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
|
@ -157,6 +159,7 @@ class IncentiveController extends Controller
|
|||
'bonus_rank_2' => 'nullable|numeric|min:0|max:999999',
|
||||
'bonus_rank_3' => 'nullable|numeric|min:0|max:999999',
|
||||
'include_sales_points' => 'nullable|boolean',
|
||||
'vip_only' => 'nullable|boolean',
|
||||
'status' => 'required|integer|in:0,1,2',
|
||||
]);
|
||||
$data = $this->normalizePayoutFields($data);
|
||||
|
|
@ -459,7 +462,12 @@ class IncentiveController extends Controller
|
|||
<a href="'.route('admin_incentive_edit', [$incentive->id]).'" class="btn icon-btn btn-sm btn-warning"><span class="fa fa-edit"></span></a>';
|
||||
})
|
||||
->addColumn('status_label', function (Incentive $incentive) {
|
||||
return '<span class="badge badge-'.$incentive->getStatusColor().'">'.$incentive->getStatusType().'</span>';
|
||||
$badge = '<span class="badge badge-'.$incentive->getStatusColor().'">'.$incentive->getStatusType().'</span>';
|
||||
if ($incentive->vip_only) {
|
||||
$badge .= ' <span class="badge badge-dark">'.__('incentive.vip_only_badge').'</span>';
|
||||
}
|
||||
|
||||
return $badge;
|
||||
})
|
||||
->addColumn('period', function (Incentive $incentive) {
|
||||
return $incentive->qualification_start->format('d.m.Y').' - '.$incentive->qualification_end->format('d.m.Y');
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ class HomeController extends Controller
|
|||
$incentiveParticipants = collect();
|
||||
|
||||
if ($user->isActiveAccount()) {
|
||||
$activeIncentives = Incentive::activeForNavigation();
|
||||
$activeIncentives = Incentive::activeForNavigation($user);
|
||||
if ($activeIncentives->isNotEmpty()) {
|
||||
$incentiveParticipants = IncentiveParticipant::query()
|
||||
->whereIn('incentive_id', $activeIncentives->pluck('id'))
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ class IncentiveController extends Controller
|
|||
->firstOrFail();
|
||||
|
||||
$user = Auth::user();
|
||||
abort_unless($incentive->isVisibleFor($user), 404);
|
||||
|
||||
$participant = IncentiveParticipant::where('incentive_id', $incentive->id)
|
||||
->where('user_id', $user->id)
|
||||
->first();
|
||||
|
|
@ -54,6 +56,8 @@ class IncentiveController extends Controller
|
|||
->firstOrFail();
|
||||
|
||||
$user = Auth::user();
|
||||
abort_unless($incentive->isVisibleFor($user), 404);
|
||||
|
||||
$participant = IncentiveParticipant::where('incentive_id', $incentive->id)
|
||||
->where('user_id', $user->id)
|
||||
->first();
|
||||
|
|
@ -97,14 +101,15 @@ class IncentiveController extends Controller
|
|||
->active()
|
||||
->firstOrFail();
|
||||
|
||||
$user = Auth::user();
|
||||
abort_unless($incentive->isVisibleFor($user), 404);
|
||||
|
||||
if (! Request::has('accept_terms')) {
|
||||
\Session()->flash('alert-error', __('incentive.terms_required'));
|
||||
|
||||
return redirect(route('user_incentive_show', [$slug]));
|
||||
}
|
||||
|
||||
$user = Auth::user();
|
||||
|
||||
$participant = IncentiveParticipant::firstOrCreate(
|
||||
[
|
||||
'incentive_id' => $incentive->id,
|
||||
|
|
@ -142,6 +147,8 @@ class IncentiveController extends Controller
|
|||
->firstOrFail();
|
||||
|
||||
$user = Auth::user();
|
||||
abort_unless($incentive->isVisibleFor($user), 404);
|
||||
|
||||
$participant = IncentiveParticipant::with('incentive', 'user', 'user.account')
|
||||
->where('incentive_id', $incentive->id)
|
||||
->where('user_id', $user->id)
|
||||
|
|
|
|||
|
|
@ -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