'int', 'reward_points' => 'int', ]; } public function recalculateTier(): void { $newTier = Tier::where('min_spending', '<=', $this->total_spending) ->where(function ($query) { $query->whereNull('max_spending') ->orWhere('max_spending', '>=', $this->total_spending); }) ->first(); if ($newTier && $newTier->id !== $this->tier_id) { $this->update(['tier_id' => $newTier->id]); } } public function tier(): BelongsTo { return $this->belongsTo(Tier::class); } public function user(): BelongsTo { return $this->belongsTo(User::class); } }