Levels
Every user has a Wealth level (from what they spend) and a Charm level (from what they receive). You design the ladders, their badges and the prizes of each step from the control panel; the feature starts empty.
By Bilal Ahmed QureshiFirst published Nov 29, 2026
About this feature
Every user has a Wealth level (from what they spend) and a Charm level (from what they receive). You design the ladders, their badges and the prizes of each step from the control panel; the feature starts empty.
What it does
- How it works: every action that spends or receives value gives experience. Sending a gift raises the sender's Wealth experience, receiving a gift raises the receiver's Charm experience, and other features (store purchases, VIP, reels, and any feature you install) can add their own sources. When the total reaches the next step of the ladder the user goes up a level, gets a push notification and an official message ("You reached Wealth/Charm level N"), and the prizes of that level are paid once. A new user starts at level 0 with no experience. If you change the ladder later, every user's level is recalculated on its own, up or down, without sending level-up messages.
- The ladders and levels: Wealth (type Sender) and Charm (type Receiver). Each ladder is a list of levels, each with its number, the experience needed and its badge picture. The feature comes empty on purpose: until you add the first level every user is at level 0 with an empty badge, and nobody loses experience, because the experience is kept even without a ladder. A third ladder, the Charge level, comes with the separate Levels Charge add-on.
- Prizes for reaching levels: for each level, a "Rewards" button opens its prize editor, where you can give coins, a VIP, a store item, and the other prize types your installed features offer. Prizes are for a level or a range of levels, are paid once per level per user, and every payout is listed in a history screen (who, which level, which prizes). The Charge ladder has no prizes.
- What you set in the control panel, in the Levels menu. Levels (tabs Wealth and Charm, plus Charge when its add-on is installed): add a level with its number, its experience and its badge picture (required), edit the level number and the experience right in the list, and open its Rewards. Level Settings: the list of experience sources, grouped by the ladder they feed (every installed feature declares its own), each with an on/off switch, a multiplier (0 to 1000), a fixed experience per action and a daily limit per user; the level curve generator, where you type how many levels, the first level's experience (500 by default) and the last level's experience (50,000,000 by default) and see a preview before you apply it, so the climb gets steeper evenly; and the conversion rate of the Charge ladder (how many XP for each recharged coin) when that add-on is installed. Bulk images: upload many badge pictures at once, each going to its level by the number in the file's name or by the order of the files (up to level 1,000); a missing level is created with the experience of the curve you chose, and a bad file never stops the others and is listed with its reason. Level Grants: give a user experience on the Wealth or Charm ladder by hand, with a reason, logged as an admin grant, and a link to it from the user form. Level change history: every manual change, with the old and new levels. Level reward screens: the intervals and their winners. Each screen is behind its own permission (including a dedicated one for giving experience), given to the admin position by default.
- Picture files: a level's badge takes JPG, PNG, WebP and GIF, up to 2 MB.
- What the user sees in the app: a Level page with two tabs, Wealth level and Charm level; each shows the user's card ("Wealth level 7"), the badge, the current experience, the experience of the next level and a progress bar, a description of what raises that ladder, and the list of all the level badges. The level badge also shows next to the name on profiles, rows and the gift sheet, where a bar says "You still need N experience to reach level N+1". The user gets a notification when they level up.
- Works with all themes: the Level page, the progress bar and the cards take their colours from the active theme, and your badge pictures show as you drew them.
- Why it is worth it for you: levels give users a visible goal. Spenders climb faster the more they gift and buy, receivers climb by being popular, and every step can pay a prize, so people keep sending gifts and coming back. You control the speed of the climb with the curve, the multipliers and the daily limits, and you can switch a source off.
- Requirements: only the base users. Gifts, the store, VIP and reels feed the ladders when they are installed, the Wallet pays coin prizes, and the Medals feature can be a prize.
Depends on
Base users. Optional: Gifts, the Store, VIP and reels as experience sources, the Wallet for coin prizes.
In the app
Swipe for more
Install and remove
After you buy, you'll also find these commands in My purchases.
Install
php artisan feature:install levels --applyRemove (your data stays)
Disable the feature in the base with one command (shown on this page). The Level page and its routes close and the badges disappear from the app. The stored experience and levels of every user are kept and come back when the feature returns.
php artisan feature:remove levelsRemove its add-ons first: removing a feature while its add-ons are installed is refused.
No add-ons for this feature yet.
Required features
This has no requirements: you can install it on its own.
Install and remove
The command sets up the feature's tables, admin panel pages, permissions, settings, and base data. In the app, the feature appears in its place on its own. The feature disappears from the app and the admin panel, and your data stays. Install it again and everything comes back as it was.
After you buy, you'll also find these commands in My purchases.
Install
php artisan feature:install levels --applyRemove (your data stays)
Disable the feature in the base with one command (shown on this page). The Level page and its routes close and the badges disappear from the app. The stored experience and levels of every user are kept and come back when the feature returns.
php artisan feature:remove levelsRemove its add-ons first: removing a feature while its add-ons are installed is refused.
Use this feature inside yours
الخلاصة بصراحة: المستويات بتقدّم للغير 3 حاجات في السيرفر (قارئ المستوى UserLevelReader، ونداء الإكسب levels.award_exp، وكتالوج السلالم)، وحاجتين في التطبيق (LevelRefresher وصف في قايمة البروفايل). الأحداث اللي الميزة بتطلّعها: UserLevelChanged (أي مستوى مخزّن اتغيّر) وusers.level_up (إكسب رفع المستوى)، والباقي بتسمعه بس. اللي مش موجود مكتوب إنه مش موجود.
التثبيت والإزالة
- تثبيت:
php artisan feature:install levels --apply(من غير--applyبيعمل dry-run يعرض بس). بيجهّز الميجريشن بتاعتها (إضافية بس) وصف مفتاح التشغيلapp_features.levels، وبعدها افتح المفتاح من اللوحة أو بـphp artisan feature:open levels. وعلى التطبيق: سطرlevelsفيtools/features.yamlيكونenabled: true. - إزالة:
php artisan feature:remove levels --apply(بيرفض لو فيه ميزة معتمدة عليها أو شغل معلّق). الجداول والمستويات المخزّنة فيusers.*_levelبتفضل زي ما هي. على التطبيق:python tools/apply_features.py --analyze-without levelsبيثبت إن باقي التطبيق بيبني من غيرها. - اعتماداتها:
base:users@1بس. مفيش ميزة تانية مطلوبة، والـVIP والمتجر والهدايا والريلز بيكمّلوا من غيرها.
الـports (سيرفر)
الـports ملك الميزة (Modules\Levels\Contracts) وهي اللي بتربط التنفيذ الحقيقي من LevelsServiceProvider::register()؛ من غير الميزة الكلاسات دي مش موجودة، فميزة مش بتعلن levels في requires تسأل بـFeatureCalls وتكتب الافتراضي:
| الـport | بيعمل إيه | من غير المستويات |
|---|---|---|
Modules\Levels\Contracts\UserLevelReader (ملك الميزة) | levelOf($user, $type) يرجّع مستوى المستخدم (النوع: 1 جاذبية، 2 ثراء)، وbadgeOf($user, $type) يرجّع صورة الشارة | الكلاس مش موجود: اسأل بـlevels.user_badge_image (الشارة) والافتراضي عندك |
نداء levels.award_exp | يدّي خبرة لمستخدم على سلم (wealth للمرسل، charm للمستقبل) من مصدر مسجّل، بمفتاح ما بيتحسبش مرتين | بيرجّع افتراضي الطالب: مفيش إكسب بيتسجّل ومفيش خطأ بيحصل |
Modules\Levels\Contracts\LevelTierCatalog (ملك الميزة، مش الأساس) | سلالم المستويات (الشرايح) — الميزات المستهلكة بتعلنه في requires (Gifts و LevelsCharge و LuckyGifts) | Modules\Levels\Services\NullLevelTierCatalog: سلم فاضي (للتستات) |
FeatureCalls levels.tier_image | (type, level) يرجّع صورة شريحة المستوى، '' لو مفيش | الميزات اللي من غير requires بتسأل بالاسم والافتراضي '' |
- مفيش
LevelRefresherفي السيرفر.LevelRefresherاسم port التطبيق بس. في السيرفر اللي بيحدّث المستوى بعد أي إكسب هوExpAwarder(بيكتب الإكسب ويظبط المستوى)، والقراية بـUserLevelReaderمابتخزّنش نسخة: كل نداء بيقرا الحالة الحالية. المستوى دايمًا محسوب من الإكسب والسلم الحالي، زيادة أو نقص، ولما الأدمن يعدّل السلم الـjobRecalculateLadderLevelsبيعيد حساب كل المستخدمين على دفعات. - ماتربطش تنفيذ تاني على نفس الـports: الميزة هي صاحبتها. وماتنادّيش أي كلاس جوه
Modules/Levelsولا جدولlevel_tiersمباشرة. - جيب الـport من الـcontainer:
app(UserLevelReader::class)في ميزة بتعلنlevelsفيrequires(الكلاس موجود طول ما المستويات متركّبة).
الأحداث
- اللي الميزة بتطلّعه: حدث نصي
users.level_up(int $userId, string $side)(side=senderثراء أوreceivedجاذبية) منlevels.award_expلما إكسب يرفع المستوى، بعد الـcommit؛ الميزة بتسمعه وتبعت رسالة الترقية (SendLevelUpMessage)، وأي ميزة تقدر تسمعه. والحدثModules\Levels\Events\UserLevelChanged. الـpayload:userId(int) وkind(senderثراء،receivedجاذبية،chargeشحن) وoldLevelوnewLevel(int، دايمًا مختلفين، وممكن المستوى ينزل بعد تعديل سلم أو أدمن). بيتبعت بعد الـcommit، مرة لكل كتابة بترتيب الكتابة، وفشل مستمعك مابيفشّلش الهدية ولا الشحن (بيتسجّل ويتبلع). استعمل(userId, kind, newLevel)مفتاح idempotency لأي جايزة (المستوى ممكن ينزل ويرجع). أي حفظ للموديل بيطلّعه لوحده، وكاتب الـraw update بيناديFeatureCallslevels.level_changed(userId, kind, oldLevel, newLevel). المستخدم اللي اتعمل بمستوى جاهز من اللوحة بيطلّعUserRegisteredبس. - اللي المستويات بتسمعه (أحداث نصية متزامنة، المرسل ميعرفش مين بيسمع):
level_tiers.changed: أي ميزة بتكتب على سلم مستويات تطلّعه، والمستويات بتمسح كاش السلالم.
FeatureCalls المسجّلة
أسئلة صغيرة بيسألها غيرها بـFeatureCalls::call('<الاسم>', <الافتراضي>, ...) والافتراضي عند السائل لو المستويات مش متركّبة:
levels.card(كارت المستوى بأنواعه، فوق) وlevels.legacy_level(user, type, isImage)وlevels.tier_image(type, level)وlevels.list_badges(people)وlevels.user_badge_image(user, side)(صورة شارةreceiverأوsender) وlevels.level_changed(userId, kind, oldLevel, newLevel)(فوق).
الداتا اللي تقدر تقراها
- اقرا بالـport مش بالجدول. الأعمدة
users.sender_levelوreceived_levelوcharge_level(ومعاهاtotal_diamond_sendوtotal_diamond_receivedوtotal_charge_coins) في البيس وتقدر تقراها، بس الكتابة فيها منlevels.award_expوإعادة الحساب بس (فيه UPDATE ذري). ماتعملش$user->sender_level += ...ولاsave()على الأعمدة دي. - علاقات
User(senderLevelوreceiverLevelوchargeLevel) بتتسجّل من الـprovider، يعني موجودة بس والميزة شغّالة. GET api/levels/badges: سلالم الشارات للتطبيق (من المستويات).- هوية المستخدم في توكن UTD Stream: الميزة بتسجّل attribute اسمه
lv="ثراء,جاذبية,شحن"(أرقام المستويات المخزّنة،"0"لسلم مالوش مستوى؛ رقم الشحن من الإضافة بـlevels_charge.charge_levels). وبتناديIdentityAttributes::changedلما رقم مستوى يتغيّر (من حدثUserLevelChanged) مش مع كل exp. صور الأرقام دي فيGET api/levels/catalog({id: {img, aspect}}، الـid حرف السلم والمستوى:s5ثراء وr3جاذبية وc2شحن، والمستوى 0 صورته فاضية، ومعاهETag/304)؛ والكتالوج وGET api/levels/identityبيقروا الصور من كلاس واحد (Support/LevelPictures).
Slots (التطبيق)
- اللي الميزة بتقدّمه للغير:
LevelRefresher(lib/src/core/base/level_refresher.dart، في البيس، والمستويات بتعملprovide):LevelRefresher.refreshMine(): يحدّث مستوى وإكسب المستخدم الحالي. نادّيه بعد أي حاجة بتغيّر الإكسب.LevelRefresher.refreshLevelPage(): يحدّث بيانات شاشة المستويات (بعد ما المستخدم يستلم هدية).LevelRefresher.bar(context, LevelBarStyle(...)): يرسم شريط تقدّم مستوى المرسل بالألوان اللي إنت تحدّدها.- من غير المستويات: الأولين مابيعملوش حاجة، و
barبيرجّعSizedBox.shrink().
- اللي بتسجّله في slots البيس:
profileMenuEntries(صفid: levels، ترتيب 5 فوق باقي الصفوف، اسمه «Level» في الكلاسيك و«Grade» في الباقي) وراوتRoutes.levelScreen. - ميزتك تفتح شاشة المستويات بـ
Navigator.pushNamed(context, Routes.levelScreen)(لو المستويات مش متركّبة الراوت مابيتحلّش).
مثال سيرفر: ميزة تكافئ المستخدم على الترقية وتعرض مستواه
use Modules\Levels\Contracts\UserLevelReader;
use Modules\Levels\Events\UserLevelChanged;
use Illuminate\Support\Facades\Event;
// في provider ميزتك (بتعلن `levels` في `requires`): المستمع على حدث المستويات
Event::listen(UserLevelChanged::class, function (UserLevelChanged $e) {
if ($e->kind !== UserLevelChanged::KIND_SENDER || $e->newLevel <= $e->oldLevel) {
return;
}
// (userId, kind, newLevel) = مفتاح التكرار: المستوى ممكن ينزل ويرجع
myFeatureGrant($e->userId, "level_reward:{$e->kind}:{$e->newLevel}");
});
// عرض المستوى
$wealth = app(UserLevelReader::class)->levelOf($user, 2);
$badge = app(UserLevelReader::class)->badgeOf($user, 2); // '' لو مفيش
// تسجيل إكسب على شراء في ميزتك (بيرجّع 0 ومابيعملش حاجة لو المستويات مش متركّبة)
\App\Support\FeatureCalls::call('levels.award_exp', 0, $user->id, 'wealth', 'mall.purchase', $price, "mall:{$orderId}");- فلوس الجايزة من ميزتك (محفظتك وميزانيتك)، مش من المستويات.
myFeatureGrantدالة ميزتك (مثال). - مصادر الإكسب المقترحة لكل ميزة:
_ops/certificate/levels-xp-sources.md.
مثال تطبيق: الهدايا بتحدّث مستوى المرسل وبترسم شريطه
ده شغّال فعلًا في ميزة الهدايا (lib/src/features/gift) من غير ما تستورد حاجة من features/levels:
import 'package:general/src/core/base/level_refresher.dart';
// بعد ما الإرسال اتأكّد (gift_send_bloc): حدّث مستوى وإكسب المرسل
LevelRefresher.refreshMine();
// لما المستخدم يستلم هدية: حدّث شاشة المستويات
LevelRefresher.refreshLevelPage();
// في شاشة الهدايا: شريط المستوى، ويختفي من غير المستويات
LevelRefresher.bar(
context,
const LevelBarStyle(
levelTextColor: Colors.amber,
progressBarColor: Colors.amber,
progressBackgroundColor: Colors.white54,
descriptionTextColor: Colors.white54,
progressBarHeight: 2,
showDivider: true,
dividerColor: Colors.white12,
),
);تستات بتقفل ده: test/gift_level_bar_test.dart وtest/gift_sent_event_test.dart وtest/levels_module_test.dart.
اعمل إضافة جوّه المستويات
بصراحة عن اللي متاح: المستويات مابتفتحش slot سيرفر للإضافات. الإضافة بتربط نفسها بالبيس (ports وأحداث) وبـlevelTabSlot في التطبيق. الإضافة الوحيدة الحالية levels_charge (مستوى الشحن)، وهي المثال الحقيقي: Modules/LevelsCharge/FEATURE.md.
feature.jsonللإضافة (الشكل الفعلي فيModules/LevelsCharge/feature.json):"kind": "addon"و"parent": "levels"(ده اللي بيتكتب في الـjson؛ فيtools/features.yamlبتاع التطبيق بيتكتبof: levels) و"requires": ["base:users@1", "levels@^1"]و"app_switch": "<slug>"و"namespace". والـslots اللي بتعلنها:data(الجداول والـalters) وroutes.apiوpanel_permissionsوpanel_screensحسب اللازم.- الملفات اللازمة:
module.json(الـprovider) وfeature.jsonوFEATURE.mdوProviders/<X>ServiceProvider.phpوmarket/listing.json(صفحة الماركت). والباقي حسب شغلها (راوتات وخدمات وميجريشن). - السيرفر: الإضافة بتسجّل نفسها في الـprovider بالطرق دي بس (كلها موجودة في الكود):
- تربط تنفيذ port من البيس:
$this->app->bind(ChargeLevel::class, EloquentChargeLevel::class)(البيس بيربط Null قبلها). - تضيف علاقة على
User:User::resolveRelationUsing('chargeLevel', ...). - تسجّل جزء في ردود البيس:
FeatureCalls::register('levels_charge.users_level', 'levels_charge', fn (User $u) => ...). - تسمع
Modules\Levels\Events\UserLevelChanged(لو عايزة تعمل حاجة لما المستوى يتغيّر). - لو الإضافة محتاجة port جديد من البيس لازم يتضاف في البيس بميزة معتمدة (مش من جوه الإضافة).
- تربط تنفيذ port من البيس:
- التطبيق: موديول بيسجّل في
levelTabSlot(features/levels/api.dart) تاب جديد في شاشة المستويات. المثال الحقيقيfeatures/levels_charge/levels_charge_module.dart:
final InternalSlot<LevelTab> chargeLevelTab = InternalSlot<LevelTab>( id: 'charge', order: 30, feature: 'levels_charge', requires: const ['levels'], builder: LevelTab(titleKey: StringManager.charge, build: (context, badges) => ChargeView(data: badges.charge)), ); // في registerDependencies: levelTabSlot.register(chargeLevelTab);
وسطر في tools/features.yaml: levels_charge: {enabled: true, paths: [features/levels_charge], components: [], of: levels} وسطر الموديول في قايمة الموديولات.
- تركيب وشيل:
php artisan feature:install <slug> --applyوphp artisan feature:remove <slug> --apply(من غير--applydry-run)، وفي التطبيقpython tools/apply_features.py --analyze-without <slug>(تحليل مش تست). - ماتعملش: ماتكتبش في
users.*_levelمباشرة (الكتابة منlevels.award_expوالـjob بتاع إعادة الحساب)، وماتفترضش إن أمك متركّبة غير بـrequires.
الإعدادات والصلاحيات والمنيو
- مفاتيح الإعدادات (جدول
configs، بتتعدّل من صفحة «Level Settings» (راوتlevel-settings، آخر بند في قسم المستويات، مش تاب في الإعدادات العامة) والحفظ فيLevelSettingsController::saveExpRatesعلىlevel-exp-rates، بصلاحيةedit-ovip-settings):exp_charge_percentageبس (نسبة إكسب الشحن، وبتظهر في التاب لو إضافة الشحن متركبة). أي ميزة تانية بتحتاج سلم أو مصدر خبرة بتضيفهم هي لما تتركب، وصفوفconfigsوlevel_tiersاللي على أي سيرفر بتفضل زي ما هي. بتتقرا بـConfigServiceProvider::getReceivedAndSanderPercentage()وبتتخزّن في كاشexp_percentagesساعة. مفتاحا الـVIP (buy_aristocracy,enable_vip_auto) بتحفظهم شاشة الـVIP علىovip-configومش بتوع المستويات. المفاتيح الخمسة بتفضل فيconfigs(بتتقرا من البيس والجوايز واللوكي)، وكلماتها فيModules/Levels/Resources/lang. سويتش التشغيل:app_features.levels(php artisan feature:open levels). - الصلاحيات (permission keys، من
feature.jsonتحتpanel_permissions، وبتتزرع وقت التركيب):level(السلالم) وlevel-user-history(تاريخ التعديل اليدوي، browse بس) وlevel-intervalوreward-level-intervalوlevel-rewards-history(browse بس، سجل الفايزين بجوايز المستوى). خمس أفعال لكل واحد (browse وcreate وedit وdelete وshow) ما عدا اللي بـbrowse بس. وصفحةvipsبتتحمي بـbrowse-level، وedit-level(فعل edit علىlevel) بتحمي تعديل مستوى مستخدم من شاشته. - المنيو (من
panel_menu): قسم «Levels» فيه:vips(Level List) وchange-level-histories(Level Change History) وlevel-settings(Level Settings، آخر بند في القسم، بصلاحيةedit-ovip-settings؛ سيرفر قديم بياخد الصف بـfeature:upgrade). سيرفر قديم فيه الصفوف دي بيتسجّلوا ملك الميزة بميجريشنrecord_the_levels_panel_rows_that_already_exist(تسجيل بس، ما بيغيّرش حاجة)، وميجريشنremove_the_room_and_cp_leftovers_from_the_levels_panelبتشيل صف منيو قديم بيشاور على راوت اتشال وبتسمّي صلاحية الفايزين باسمها الجديد، فتقفيل الميزة بيخفيهم. - لسه في البيس بصراحة: حساب
exp_percentagesفيConfigServiceProvider(بتقراه كل الميزات)؛ وزرار تعديل المستوى في بروفايل المستخدمedit-level(UserController).
لو المستويات مش متركّبة (أو مقفولة)
- السيرفر: القارئ بيرجّع
0والشارة''، ونداءlevels.award_expمابيعملش حاجة، والكتالوج فاضي، وصفحة «Level Settings» وراوتاتlevel-exp-ratesوlevel-exp-sourcesوlevel-curve-previewوlevel-curve-applyبتختفي، وراوتlevels/badgesبيختفي (404)، ومفيش جوايز ترقية. الأعمدةusers.*_levelبتفضل بقيمها. حدثUserLevelChangedبيفضل يتبعت لو حد غير المستويات حرّك المستوى (الأدمن مثلًا)، فمستمعك يشتغل عادي. - التطبيق: صف «المستوى» بيختفي من البروفايل (وشريحة الثراء في الثيم 3 كمان)، والراوتين مابيتحلّوش، و
LevelRefresher.barبيرجّعSizedBox.shrink()، وrefreshMineوrefreshLevelPageمابيعملوش حاجة. - ميزتك لازم تشتغل كاملة من غيرها: ماتفترضش إن المستوى > 0 ولا إن حدث الترقية هيجي، وماتعتمدش على
class_existsلكلاساتModules\Levels(الـautoload ممكن يفضل شغّال).
What's new
2.22.1Released Nov 29, 2026By Bilal Ahmed Qureshi
- Release 2.22.1 (signed build 3044b2c)