'k7x2', 'inactive' => 'q9m1', ]; public static function encodeStatus($status) { return self::STATUS_MAP[$status] ?? self::STATUS_INACTIVE; } public static function decodeStatus($dbValue) { static $reverse = null; if ($reverse === null) { $reverse = array_flip(self::STATUS_MAP); } return $reverse[$dbValue] ?? 'inactive'; } public static function isActiveStatus($dbValue) { return $dbValue === self::STATUS_ACTIVE; } public static function label() { return __eva('Extensions'); } /** * Static metadata for all available addons (never stored in DB) */ public static function addonsCatalog(): array { return [ // ── Bundles ──────────────────────────────────────────────── /*'bundle_growth' => [ 'name' => 'Growth Bundle', 'description' => 'WhatsApp Reservations + Missed Call Booking. Everything you need to capture every reservation.', 'url' => 'https://alexreservations.com/pricing', 'icon' => 'bundle', 'image' => self::CDN . '/bundle-whatsapp-missed-calls.webp', 'badge' => 'Bundle', 'badge_color' => '#eff6ff', 'badge_text_color' => '#1d4ed8', 'title_color' => '#1d4ed8', 'title_color_dark' => '#93c5fd', 'is_bundle' => true, 'includes' => ['addon_whatsapp', 'addon_missed_call'], ], 'bundle_revenue' => [ 'name' => 'Revenue Bundle', 'description' => 'WhatsApp Reservations + Missed Call Booking + Premium Tables. The complete toolkit to maximize your revenue.', 'url' => 'https://alexreservations.com/pricing', 'icon' => 'bundle', 'image' => self::CDN . '/bundle-whatsapp-missed-calls-tables.webp', 'badge' => 'Bundle', 'badge_color' => '#fdf4ff', 'badge_text_color' => '#7e22ce', 'title_color' => '#7e22ce', 'title_color_dark' => '#d8b4fe', 'is_bundle' => true, 'includes' => ['addon_whatsapp', 'addon_missed_call', 'addon_tables_revenue'], ],*/ // ── Individual modules ───────────────────────────────────── 'addon_whatsapp' => [ 'name' => 'WhatsApp Reservations', 'description' => 'Accept reservations and confirmations via WhatsApp.', 'url' => 'https://alexreservations.com/modules/whatsapp-reservations', 'icon' => 'whatsapp', 'image' => self::CDN . '/module-whatsapp-reservations-2.webp', 'badge' => 'Popular', 'badge_color' => '#dcfce7', 'badge_text_color' => '#15803d', 'title_color' => '#128c7e', 'title_color_dark' => '#4ade80', 'is_bundle' => false, 'includes' => [], ], 'addon_missed_call' => [ 'name' => 'Missed Call Booking', 'description' => 'Recover reservations automatically from missed calls.', 'url' => 'https://alexreservations.com/modules/missed-call-booking', 'icon' => 'phone-x', 'image' => self::CDN . '/module-missed-call-booking-2.webp', 'badge' => null, 'badge_color' => '#fef3c7', 'badge_text_color' => '#b45309', 'title_color' => '#d97706', 'title_color_dark' => '#fcd34d', 'is_bundle' => false, 'includes' => [], ], 'addon_tables_revenue' => [ 'name' => 'Premium Tables', 'description' => 'Increase revenue with premium table pricing.', 'url' => 'https://alexreservations.com/modules/premium-tables', 'icon' => 'tag', 'image' => self::CDN . '/module-premium-tables-2.webp', 'badge' => null, 'badge_color' => '#ede9fe', 'badge_text_color' => '#5b21b6', 'title_color' => '#4f46e5', 'title_color_dark' => '#a5b4fc', 'is_bundle' => false, 'includes' => [], ], 'addon_offers' => [ 'name' => 'Custom Menus & Offers', 'description' => 'Let guests choose set menus and special offers directly from the booking form.', 'url' => 'https://alexreservations.com/modules/booking-offers', 'icon' => 'fork-knife', 'image' => self::CDN . '/module-premium-tables-2.webp', 'badge' => null, 'badge_color' => '#fce7f3', 'badge_text_color' => '#9d174d', 'title_color' => '#db2777', 'title_color_dark' => '#f9a8d4', 'is_bundle' => false, 'includes' => [], ], 'addon_api_bots' => [ 'name' => 'API for bots', 'description' => 'Create, query and manage reservations via a REST API for chatbots and integrations.', 'url' => 'https://alexreservations.com/modules/api-bots', 'icon' => 'robot', 'image' => self::CDN . '/module-premium-tables-2.webp', 'badge' => null, 'badge_color' => '#cffafe', 'badge_text_color' => '#155e75', 'title_color' => '#0891b2', 'title_color_dark' => '#67e8f9', 'is_bundle' => false, 'includes' => [], ], 'addon_gift_cards' => [ 'name' => 'Gift Vouchers', 'description' => 'Sell gift vouchers online and let guests redeem them when they book.', 'url' => 'https://alexreservations.com/modules/gift-vouchers', 'icon' => 'gift', 'image' => self::CDN . '/module-premium-tables-2.webp', 'badge' => 'New', 'badge_color' => '#fef9c3', 'badge_text_color' => '#a16207', 'title_color' => '#ca8a04', 'title_color_dark' => '#fde047', 'is_bundle' => false, 'includes' => [], ], ]; } /** * Default DB values for each addon (only these fields are stored) */ public static function defaultAddonsData() { $data = []; foreach (array_keys(self::addonsCatalog()) as $slug) { $data[] = [ 'slug' => $slug, 'license' => '', 'status' => self::STATUS_INACTIVE, ]; } return $data; } public static function getId($tenantId) { $addon = Addon::where(self::$pivot_tenant_field, $tenantId)->first(); if ($addon) { return $addon->id; } $addon = Addon::create([ 'restaurant_id' => $tenantId, 'meta_value' => [ 'config' => [ 'addons' => self::defaultAddonsData() ] ] ]); return $addon->id; } public static function getItems(AppSettingsRequest $request, $tenantId) { $addonId = Addon::getId($tenantId); $addon = Addon::find($addonId); $config = $addon->config ?? []; $savedAddons = $config['addons'] ?? []; $catalog = self::addonsCatalog(); $merged = []; // For each addon in catalog, merge static metadata with saved DB data foreach ($catalog as $slug => $meta) { $saved = null; foreach ($savedAddons as $s) { if ($s['slug'] === $slug) { $saved = $s; break; } } $dbStatus = $saved['status'] ?? self::STATUS_INACTIVE; $merged[] = array_merge( ['slug' => $slug], $meta, [ 'license' => $saved['license'] ?? '', 'status' => self::decodeStatus($dbStatus), ] ); } return ['addons' => $merged]; } }