-- https://www.phpmyadmin.net/
--
-- إصدار الخادم: 10.11.14-MariaDB

START TRANSACTION;



--
-- Database: `pioneergym_shapooov`
--

-- --------------------------------------------------------

--
-- بنية الجدول `branches`
--

CREATE TABLE `branches` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `branch_code` varchar(10) NOT NULL,
  `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`name`)),
  `branch_category_id` bigint(20) UNSIGNED NOT NULL,
  `branch_type_id` bigint(20) UNSIGNED NOT NULL,
  `city_id` bigint(20) UNSIGNED NOT NULL,
  `primary_phone` varchar(255) NOT NULL,
  `phones` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`phones`)),
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `address` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`address`)),
  `min_age` tinyint(3) UNSIGNED DEFAULT NULL,
  `max_discount_percent` decimal(5,2) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `branches`
--

INSERT INTO `branches` (`id`, `branch_code`, `name`, `branch_category_id`, `branch_type_id`, `city_id`, `primary_phone`, `phones`, `active`, `address`, `min_age`, `max_discount_percent`, `created_at`, `updated_at`) VALUES
(1, '001', '{\"ar\":\"فرع القيروان\",\"en\":\"Al-Qirawan Club\"}', 2, 1, 4, '0560855525', '[{\"label\":{\"ar\":\"Ahmed Aldosary\",\"en\":\"Ahmed Aldosary\"},\"number\":\"0560855525\"}]', 1, '{\"full\":{\"ar\":null,\"en\":null},\"short\":{\"ar\":null,\"en\":null},\"street\":{\"ar\":null,\"en\":null},\"district\":{\"ar\":null,\"en\":null},\"building_no\":null,\"postal_code\":null,\"tax_no\":null}', NULL, NULL, '2025-12-15 06:48:15', '2025-12-15 06:48:15');

-- --------------------------------------------------------

--
-- بنية الجدول `branch_categories`
--

CREATE TABLE `branch_categories` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`name`)),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `branch_categories`
--

INSERT INTO `branch_categories` (`id`, `name`, `created_at`, `updated_at`) VALUES
(1, '{\"ar\":\"نادي نسائي\",\"en\":\"Women Gym\"}', '2025-10-19 04:46:25', '2025-10-19 04:46:25'),
(2, '{\"ar\":\"نادي رجالي\",\"en\":\"Men Gym\"}', '2025-10-19 04:46:25', '2025-10-19 04:46:25'),
(3, '{\"ar\":\"نادي عائلي\",\"en\":\"Family Gym\"}', '2025-10-19 04:46:25', '2025-10-19 04:46:25');

-- --------------------------------------------------------

--
-- بنية الجدول `branch_monthly_goals`
--

CREATE TABLE `branch_monthly_goals` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `branch_id` bigint(20) UNSIGNED NOT NULL,
  `year` smallint(6) NOT NULL,
  `month` tinyint(4) NOT NULL,
  `actual` decimal(12,2) NOT NULL DEFAULT 0.00,
  `target` decimal(12,2) NOT NULL DEFAULT 0.00,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `branch_service_provided`
--

CREATE TABLE `branch_service_provided` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `service_id` bigint(20) UNSIGNED NOT NULL,
  `branch_id` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `branch_service_provided`
--

INSERT INTO `branch_service_provided` (`id`, `service_id`, `branch_id`) VALUES
(4, 1, 1),
(5, 3, 1);

-- --------------------------------------------------------

--
-- بنية الجدول `branch_service_sold`
--

CREATE TABLE `branch_service_sold` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `service_id` bigint(20) UNSIGNED NOT NULL,
  `branch_id` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `branch_service_sold`
--

INSERT INTO `branch_service_sold` (`id`, `service_id`, `branch_id`) VALUES
(2, 1, 1),
(4, 3, 1);

-- --------------------------------------------------------

--
-- بنية الجدول `branch_types`
--

CREATE TABLE `branch_types` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`name`)),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `branch_types`
--

INSERT INTO `branch_types` (`id`, `name`, `created_at`, `updated_at`) VALUES
(1, '{\"ar\":\"رئيسي\",\"en\":\"Main\"}', '2025-10-19 04:46:25', '2025-10-19 04:46:25'),
(2, '{\"ar\":\"فرعي\",\"en\":\"Sub\"}', '2025-10-19 04:46:25', '2025-10-19 04:46:25'),
(3, '{\"ar\":\"امتياز\",\"en\":\"Franchise\"}', '2025-10-19 04:46:25', '2025-10-19 04:46:25');

-- --------------------------------------------------------

--
-- بنية الجدول `cities`
--

CREATE TABLE `cities` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`name`)),
  `state_id` bigint(20) UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `cities`
--

INSERT INTO `cities` (`id`, `name`, `state_id`, `created_at`, `updated_at`) VALUES
(1, '{\"ar\":\"مدينة نصر\",\"en\":\"Nasr City\"}', 1, '2025-10-19 04:46:20', '2025-10-19 04:46:20'),
(2, '{\"ar\":\"الزمالك\",\"en\":\"Zamalek\"}', 1, '2025-10-19 04:46:20', '2025-10-19 04:46:20'),
(3, '{\"ar\":\"الملز\",\"en\":\"Olaya\"}', 4, '2025-10-19 04:46:20', '2025-10-19 04:46:20'),
(4, '{\"ar\":\"الخبر\",\"en\":\"Al-Khobar\"}', 4, '2025-10-19 04:46:20', '2025-10-19 04:46:20'),
(5, '{\"ar\":\"الخليج الغربي\",\"en\":\"West Bay\"}', 13, '2025-10-19 04:46:22', '2025-10-19 04:46:22'),
(6, '{\"ar\":\"السد\",\"en\":\"Al Sadd\"}', 13, '2025-10-19 04:46:22', '2025-10-19 04:46:22');

-- --------------------------------------------------------

--
-- بنية الجدول `company_settings`
--

CREATE TABLE `company_settings` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`name`)),
  `logo_path` varchar(255) DEFAULT NULL,
  `primary_color` varchar(255) NOT NULL DEFAULT '#0ea5b6',
  `secondary_color` varchar(255) NOT NULL DEFAULT '#1e293b',
  `email` varchar(255) DEFAULT NULL,
  `phones` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`phones`)),
  `country_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `company_settings`
--

INSERT INTO `company_settings` (`id`, `name`, `logo_path`, `primary_color`, `secondary_color`, `email`, `phones`, `country_id`, `created_at`, `updated_at`) VALUES
(1, '{\"ar\":\"الشركة النموذجية\",\"en\":\"Demo Company\"}', NULL, '#0ea5b6', '#1e293b', 'info@example.com', '[{\"label\":{\"ar\":\"\\u0627\\u0644\\u0645\\u0628\\u064a\\u0639\\u0627\\u062a\",\"en\":\"Sales\"},\"number\":\"+201234567890\"},{\"label\":{\"ar\":\"\\u0627\\u0644\\u062f\\u0639\\u0645\",\"en\":\"Support\"},\"number\":\"+201112223334\"}]', 2, '2025-10-19 04:46:24', '2025-10-19 04:46:24');

-- --------------------------------------------------------

--
-- بنية الجدول `countries`
--

CREATE TABLE `countries` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`name`)),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `countries`
--

INSERT INTO `countries` (`id`, `name`, `created_at`, `updated_at`) VALUES
(1, '{\"ar\":\"مصر\",\"en\":\"Egypt\"}', '2025-10-19 04:46:20', '2025-10-19 04:46:20'),
(2, '{\"ar\":\"السعودية\",\"en\":\"Saudi Arabia\"}', '2025-10-19 04:46:20', '2025-10-19 04:46:20'),
(3, '{\"ar\":\"الإمارات\",\"en\":\"United Arab Emirates\"}', '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(4, '{\"ar\":\"الأردن\",\"en\":\"Jordan\"}', '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(5, '{\"ar\":\"لبنان\",\"en\":\"Lebanon\"}', '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(6, '{\"ar\":\"الجزائر\",\"en\":\"Algeria\"}', '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(7, '{\"ar\":\"المغرب\",\"en\":\"Morocco\"}', '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(8, '{\"ar\":\"تونس\",\"en\":\"Tunisia\"}', '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(9, '{\"ar\":\"العراق\",\"en\":\"Iraq\"}', '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(10, '{\"ar\":\"الكويت\",\"en\":\"Kuwait\"}', '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(11, '{\"ar\":\"عمان\",\"en\":\"Oman\"}', '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(12, '{\"ar\":\"قطر\",\"en\":\"Qatar\"}', '2025-10-19 04:46:22', '2025-10-19 04:46:22'),
(13, '{\"ar\":\"البحرين\",\"en\":\"Bahrain\"}', '2025-10-19 04:46:23', '2025-10-19 04:46:23'),
(14, '{\"ar\":\"فلسطين\",\"en\":\"Palestine\"}', '2025-10-19 04:46:23', '2025-10-19 04:46:23'),
(15, '{\"ar\":\"سوريا\",\"en\":\"Syria\"}', '2025-10-19 04:46:23', '2025-10-19 04:46:23'),
(16, '{\"ar\":\"اليمن\",\"en\":\"Yemen\"}', '2025-10-19 04:46:23', '2025-10-19 04:46:23');

-- --------------------------------------------------------

--
-- بنية الجدول `customers`
--

CREATE TABLE `customers` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `customer_code` varchar(7) NOT NULL,
  `branch_id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `customers`
--

INSERT INTO `customers` (`id`, `customer_code`, `branch_id`, `name`, `created_at`, `updated_at`) VALUES
(1, '0100001', 1, 'مستشفى الحبيب', '2025-12-16 09:56:51', '2025-12-16 09:56:51'),
(2, '0100002', 1, 'STC', '2025-12-16 09:57:46', '2025-12-16 09:57:46'),
(3, '0100003', 1, 'مسك', '2025-12-16 09:58:49', '2025-12-16 09:58:49'),
(4, '0100004', 1, 'وزارة الداخلية', '2025-12-16 09:59:24', '2025-12-16 09:59:24'),
(5, '0100005', 1, 'فري ايزي', '2025-12-17 08:50:17', '2025-12-17 08:50:17');

-- --------------------------------------------------------

--
-- بنية الجدول `failed_jobs`
--

CREATE TABLE `failed_jobs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `uuid` varchar(255) NOT NULL,
  `connection` text NOT NULL,
  `queue` text NOT NULL,
  `payload` longtext NOT NULL,
  `exception` longtext NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `members`
--

CREATE TABLE `members` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `member_code` char(7) NOT NULL,
  `branch_id` bigint(20) UNSIGNED NOT NULL,
  `status` enum('new','active','inactive') NOT NULL DEFAULT 'new',
  `id_type` enum('national_id','residence','passport','driving_license','work_card') DEFAULT NULL,
  `id_number` varchar(20) DEFAULT NULL,
  `id_issue_greg` date DEFAULT NULL,
  `id_expiry_greg` date DEFAULT NULL,
  `id_issue_hijri` varchar(20) DEFAULT NULL,
  `id_expiry_hijri` varchar(20) DEFAULT NULL,
  `name` varchar(255) NOT NULL,
  `gender` enum('male','female') DEFAULT NULL,
  `nationality_id` bigint(20) UNSIGNED DEFAULT NULL,
  `birth_greg` date DEFAULT NULL,
  `birth_hijri` varchar(20) DEFAULT NULL,
  `age` smallint(5) UNSIGNED DEFAULT NULL,
  `phone` varchar(30) DEFAULT NULL,
  `email` varchar(255) DEFAULT NULL,
  `po_box` varchar(50) DEFAULT NULL,
  `postal_code` varchar(20) DEFAULT NULL,
  `address` varchar(255) DEFAULT NULL,
  `avatar_path` varchar(255) DEFAULT NULL,
  `id_image_path` varchar(255) DEFAULT NULL,
  `work_card_image_path` varchar(255) DEFAULT NULL,
  `how_heard` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`how_heard`)),
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `members`
--

INSERT INTO `members` (`id`, `member_code`, `branch_id`, `status`, `id_type`, `id_number`, `id_issue_greg`, `id_expiry_greg`, `id_issue_hijri`, `id_expiry_hijri`, `name`, `gender`, `nationality_id`, `birth_greg`, `birth_hijri`, `age`, `phone`, `email`, `po_box`, `postal_code`, `address`, `avatar_path`, `id_image_path`, `work_card_image_path`, `how_heard`, `created_at`, `updated_at`) VALUES
(1, '0100001', 1, 'new', 'national_id', '1074589944', '2025-07-17', '2028-06-28', '1447-01-22', '1450-02-05', 'عبدالله الربيعة', 'male', 2, '1990-06-25', '1410-12-03', 35, NULL, NULL, NULL, NULL, NULL, 'uploads/members/avatar/20251215_095517_FxhsaMmL.jpg', NULL, NULL, '[]', '2025-12-15 06:55:27', '2025-12-15 06:55:27'),
(2, '0100002', 1, 'new', NULL, NULL, NULL, NULL, NULL, NULL, 'احم', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '[]', '2025-12-15 13:09:33', '2025-12-15 13:09:33'),
(3, '0100003', 1, 'new', 'national_id', '1102185621', '2021-02-23', '2025-12-25', '1442-07-11', '1447-07-05', 'احمد الدوسري', 'male', 2, '1998-03-12', '1418-11-14', 27, NULL, NULL, NULL, NULL, NULL, 'uploads/members/avatar/20251215_161330_Al3DP5OR.jpg', NULL, NULL, '[]', '2025-12-15 13:13:31', '2025-12-15 13:13:31'),
(4, '0100004', 1, 'new', 'national_id', '1234567852', '2025-12-11', '2027-06-09', '1447-06-20', '1449-01-04', 'عثمان', 'male', 2, '1997-11-27', '1418-07-27', 28, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '[]', '2025-12-15 13:23:43', '2025-12-15 13:23:43'),
(5, '0100005', 1, 'new', NULL, '1478562358', '2025-11-16', '2025-03-16', '1447-05-25', '1446-09-16', 'سالم', 'male', 2, '1994-12-06', '1415-07-04', 31, '0560594322', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '[\"friend\"]', '2025-12-16 07:40:44', '2025-12-16 07:55:00'),
(6, '0100006', 1, 'new', 'national_id', '1983542365', '2022-06-09', '2026-07-13', '1443-11-10', '1448-01-28', 'خالد احمد', 'male', 2, '2002-06-22', '1423-04-11', 23, '0560594322', 'leeka201177@gmail.com', NULL, NULL, 'الرياض', NULL, NULL, NULL, '[]', '2025-12-16 08:00:23', '2025-12-16 08:00:23'),
(7, '0100007', 1, 'new', 'national_id', '1475232365', '2022-11-29', NULL, '1444-05-05', NULL, 'كولمن', 'male', 2, '2003-03-10', '1424-01-07', 22, '0560594322', 'leeka201177@gmail.com', NULL, NULL, NULL, NULL, NULL, NULL, '[\"flyer\"]', '2025-12-16 10:01:34', '2025-12-16 10:01:34'),
(8, '0100008', 1, 'active', 'national_id', '1203654210', '2023-06-08', '2026-01-06', '1444-11-19', '1447-07-17', 'عادل الموسي', 'male', 2, NULL, NULL, NULL, '0547521245', 'admin@system.local', NULL, NULL, NULL, NULL, NULL, NULL, '[\"friend\"]', '2025-12-17 08:41:57', '2025-12-17 08:41:57'),
(9, '0100009', 1, 'active', 'national_id', '1147258963', '2024-01-15', '2026-05-06', '1445-07-03', '1447-11-19', 'محمد احمد', 'male', 2, '2006-05-02', '1427-04-04', 19, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '[\"flyer\"]', '2025-12-17 09:00:20', '2025-12-17 09:00:20'),
(10, '0100010', 1, 'active', 'national_id', '1236547582', '2024-05-07', '2025-03-03', '1445-10-28', '1446-09-03', 'حامد', 'male', 2, '2024-07-08', '1446-01-02', 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '[\"friend\"]', '2025-12-17 09:13:29', '2025-12-17 09:13:29'),
(11, '0100011', 1, 'active', 'passport', 'A13011131', '2025-12-06', '2026-04-02', '1447-06-15', '1447-10-14', 'ماهر', 'male', 11, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '[]', '2025-12-17 09:21:19', '2025-12-17 09:21:19'),
(12, '0100012', 1, 'active', 'national_id', '1032544412', '2025-12-20', '2025-12-13', '1447-06-29', '1447-06-22', 'محمد اودن', 'male', 2, '2025-12-20', '1447-06-29', 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '[]', '2025-12-17 10:45:37', '2025-12-19 12:46:19'),
(13, '0100013', 1, 'new', 'national_id', '1046541210', '2025-12-10', '2025-12-05', '1447-06-19', '1447-06-14', 'اااتا', 'male', 2, '2000-06-21', '1421-03-19', 25, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '[]', '2025-12-17 10:50:50', '2025-12-17 10:50:50'),
(14, '0100014', 1, 'active', 'national_id', '1110232540', '2020-11-18', '2028-05-08', '1442-04-03', '1449-12-13', 'محمد الجطيلي', 'male', 2, '1988-06-27', '1408-11-13', 37, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '[]', '2025-12-17 11:42:04', '2025-12-22 10:39:20'),
(15, '0100015', 1, 'inactive', 'national_id', '1083205813', '2024-02-28', '2029-05-14', '1445-08-18', '1451-01-01', 'حسين ابو بحر', 'male', 2, '1993-09-30', '1414-04-14', 32, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '[]', '2025-12-17 11:46:57', '2025-12-22 09:33:33'),
(16, '0100016', 1, 'active', 'national_id', '1045114552', '2022-10-18', '2028-06-13', '1444-03-22', '1450-01-20', 'عمر ابراهيم الجطيلي', 'male', 2, '1996-06-04', '1417-01-18', 29, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, '[]', '2025-12-22 10:41:22', '2025-12-22 10:41:22');

-- --------------------------------------------------------

--
-- بنية الجدول `member_sequences`
--

CREATE TABLE `member_sequences` (
  `branch_id` bigint(20) UNSIGNED NOT NULL,
  `prefix` char(2) NOT NULL,
  `last_seq` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `member_sequences`
--

INSERT INTO `member_sequences` (`branch_id`, `prefix`, `last_seq`, `created_at`, `updated_at`) VALUES
(1, '01', 16, '2025-12-15 06:55:27', '2025-12-22 10:41:22');

-- --------------------------------------------------------

--
-- بنية الجدول `migrations`
--

CREATE TABLE `migrations` (
  `id` int(10) UNSIGNED NOT NULL,
  `migration` varchar(255) NOT NULL,
  `batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `migrations`
--

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '2014_01_20_195147_create_countries_table', 1),
(2, '2014_01_20_195616_create_states_table', 1),
(3, '2014_01_20_195637_create_cities_table', 1),
(4, '2014_01_25_060108_create_branch_categories_table', 1),
(5, '2014_01_25_062659_create_branch_types_table', 1),
(6, '2014_01_25_082216_create_branches_table', 1),
(7, '2014_10_12_000000_create_users_table', 1),
(8, '2014_10_12_100000_create_password_reset_tokens_table', 1),
(9, '2014_10_12_100000_create_password_resets_table', 1),
(10, '2019_08_19_000000_create_failed_jobs_table', 1),
(11, '2019_12_14_000001_create_personal_access_tokens_table', 1),
(12, '2025_09_25_071042_create_company_settings_table', 1),
(13, '2025_09_25_082331_create_branch_monthly_goals_table', 1),
(14, '2025_09_25_170137_create_service_types_table', 1),
(15, '2025_09_25_172350_create_service_categories_table', 1),
(16, '2025_09_25_184345_create_services_table', 1),
(17, '2025_10_03_195032_create_customers_table', 1),
(18, '2025_10_03_204536_create_members_table', 1),
(19, '2025_10_03_231239_create_member_sequences_table', 1),
(20, '2025_10_06_075050_create_offers_table', 1),
(21, '2025_10_06_075203_create_offer_items_table', 1),
(22, '2025_10_18_120945_create_permission_tables', 1);

-- --------------------------------------------------------

--
-- بنية الجدول `model_has_permissions`
--

CREATE TABLE `model_has_permissions` (
  `permission_id` bigint(20) UNSIGNED NOT NULL,
  `model_type` varchar(255) NOT NULL,
  `model_id` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- --------------------------------------------------------

--
-- بنية الجدول `model_has_roles`
--

CREATE TABLE `model_has_roles` (
  `role_id` bigint(20) UNSIGNED NOT NULL,
  `model_type` varchar(255) NOT NULL,
  `model_id` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `model_has_roles`
--

INSERT INTO `model_has_roles` (`role_id`, `model_type`, `model_id`) VALUES
(1, 'App\\Models\\User', 1),
(1, 'App\\Models\\User', 2),
(1, 'App\\Models\\User', 3);

-- --------------------------------------------------------

--
-- بنية الجدول `offers`
--

CREATE TABLE `offers` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `offer_no` bigint(20) UNSIGNED NOT NULL,
  `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`name`)),
  `scope` enum('all','members','customers','coupons') NOT NULL DEFAULT 'all',
  `target_member_ids` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`target_member_ids`)),
  `target_customer_ids` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`target_customer_ids`)),
  `coupon_codes` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`coupon_codes`)),
  `start_date_g` date NOT NULL,
  `end_date_g` date NOT NULL,
  `start_date_h` varchar(20) DEFAULT NULL,
  `end_date_h` varchar(20) DEFAULT NULL,
  `duration_days` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `discount_type` enum('percent','amount') NOT NULL DEFAULT 'percent',
  `discount_value` decimal(10,2) NOT NULL DEFAULT 0.00,
  `extra_days` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `offers`
--

INSERT INTO `offers` (`id`, `offer_no`, `name`, `scope`, `target_member_ids`, `target_customer_ids`, `coupon_codes`, `start_date_g`, `end_date_g`, `start_date_h`, `end_date_h`, `duration_days`, `discount_type`, `discount_value`, `extra_days`, `active`, `created_at`, `updated_at`) VALUES
(1, 1, '{\"ar\":\"\\u0639\\u0631\\u0636 \\u0627\\u0644\\u0627\\u0641\\u062a\\u062a\\u0627\\u062d\",\"en\":\"\\u0639\\u0631\\u0636 \\u0627\\u0644\\u0627\\u0641\\u062a\\u062a\\u0627\\u062d\"}', 'members', NULL, NULL, NULL, '2025-12-15', '2026-01-02', '1447-06-25', '1447-07-13', 19, 'percent', 30.00, 30, 1, '2025-12-15 07:05:09', '2025-12-15 07:05:09'),
(2, 2, '{\"ar\":\"\\u064a\\u0648\\u0645 \\u0627\\u0644\\u0648\\u0637\\u0646\\u064a\",\"en\":\"\\u064a\\u0648\\u0645 \\u0627\\u0644\\u0648\\u0637\\u0646\\u064a\"}', 'members', NULL, NULL, NULL, '2025-01-22', '2025-06-22', '1446-07-23', '1446-12-26', 152, 'percent', 30.00, 15, 1, '2025-12-15 13:22:45', '2025-12-15 13:22:45'),
(3, 3, '{\"ar\":\"\\u0645\\u0633\\u062a\\u0634\\u0641\\u0649 \\u0627\\u0644\\u062d\\u0628\\u064a\\u0628\",\"en\":\"\\u0645\\u0633\\u062a\\u0634\\u0641\\u0649 \\u0627\\u0644\\u062d\\u0628\\u064a\\u0628\"}', 'customers', NULL, NULL, NULL, '2026-01-01', '2026-04-08', '1447-07-12', '1447-10-20', 98, 'percent', 30.00, 30, 1, '2025-12-16 10:37:18', '2025-12-16 10:37:18'),
(4, 4, '{\"ar\":\"\\u0645\\u0633\\u0643\",\"en\":\"\\u0645\\u0633\\u0643\"}', 'customers', NULL, NULL, NULL, '2026-06-01', '2026-10-16', '1447-12-16', '1448-05-06', 138, 'percent', 40.00, 30, 1, '2025-12-16 11:26:48', '2025-12-16 11:26:48'),
(5, 5, '{\"ar\":\"STC\",\"en\":\"STC\"}', 'customers', NULL, NULL, NULL, '2026-04-01', '2026-08-05', '1447-10-13', '1448-02-22', 127, 'percent', 30.00, 30, 1, '2025-12-17 08:06:02', '2025-12-17 08:06:02'),
(6, 6, '{\"ar\":\"\\u064a\\u0648\\u0645 \\u0627\\u0644\\u062a\\u0627\\u0633\\u064a\\u0633\",\"en\":\"\\u064a\\u0648\\u0645 \\u0627\\u0644\\u062a\\u0627\\u0633\\u064a\\u0633\"}', 'members', NULL, NULL, NULL, '2026-01-01', '2026-03-30', '1447-07-12', '1447-10-11', 89, 'percent', 10.00, 30, 1, '2025-12-17 08:09:00', '2025-12-17 08:09:00'),
(7, 7, '{\"ar\":\"\\u0641\\u0631\\u064a \\u0627\\u064a\\u0632\\u064a\",\"en\":\"\\u0641\\u0631\\u064a \\u0627\\u064a\\u0632\\u064a\"}', 'customers', NULL, NULL, NULL, '2026-01-17', '2026-04-29', '1447-07-28', '1447-11-12', 103, 'percent', 50.00, 30, 1, '2025-12-17 08:55:05', '2025-12-17 08:55:05');

-- --------------------------------------------------------

--
-- بنية الجدول `offer_items`
--

CREATE TABLE `offer_items` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `offer_id` bigint(20) UNSIGNED NOT NULL,
  `service_id` bigint(20) UNSIGNED NOT NULL,
  `service_name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`service_name`)),
  `base_price` decimal(10,2) NOT NULL,
  `base_duration_value` int(10) UNSIGNED NOT NULL,
  `base_duration_unit` enum('days','months','years') NOT NULL,
  `row_discount_type` enum('percent','amount') DEFAULT NULL,
  `row_discount_value` decimal(10,2) DEFAULT NULL,
  `row_extra_days` int(10) UNSIGNED DEFAULT NULL,
  `final_price` decimal(10,2) NOT NULL,
  `final_duration_value` int(10) UNSIGNED NOT NULL,
  `final_duration_unit` enum('days','months','years') NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `offer_items`
--

INSERT INTO `offer_items` (`id`, `offer_id`, `service_id`, `service_name`, `base_price`, `base_duration_value`, `base_duration_unit`, `row_discount_type`, `row_discount_value`, `row_extra_days`, `final_price`, `final_duration_value`, `final_duration_unit`, `created_at`, `updated_at`) VALUES
(1, 1, 1, '\"\\u0627\\u0634\\u062a\\u0631\\u0627\\u0643 3 \\u0623\\u0634\\u0647\\u0631\"', 2000.00, 3, 'months', NULL, NULL, NULL, 1400.00, 3, 'months', '2025-12-15 07:05:09', '2025-12-15 07:05:09'),
(2, 2, 1, '\"\\u0627\\u0634\\u062a\\u0631\\u0627\\u0643 3 \\u0623\\u0634\\u0647\\u0631\"', 2000.00, 3, 'months', NULL, NULL, NULL, 1400.00, 3, 'months', '2025-12-15 13:22:45', '2025-12-15 13:22:45'),
(3, 3, 2, '\"\\u0627\\u062d\\u0645\\u062f \\u0627\\u0644\\u062f\\u0648\\u0633\\u0631\\u064a\"', 2000.00, 1, 'months', NULL, NULL, NULL, 1400.00, 1, 'months', '2025-12-16 10:37:18', '2025-12-16 10:37:18'),
(4, 3, 1, '\"\\u0627\\u0634\\u062a\\u0631\\u0627\\u0643 3 \\u0623\\u0634\\u0647\\u0631\"', 2000.00, 3, 'months', NULL, NULL, NULL, 1400.00, 3, 'months', '2025-12-16 10:37:18', '2025-12-16 10:37:18'),
(5, 4, 1, '\"\\u0627\\u0634\\u062a\\u0631\\u0627\\u0643 3 \\u0623\\u0634\\u0647\\u0631\"', 2000.00, 3, 'months', NULL, NULL, NULL, 1200.00, 3, 'months', '2025-12-16 11:26:48', '2025-12-16 11:26:48'),
(6, 5, 1, '\"\\u0627\\u0634\\u062a\\u0631\\u0627\\u0643 3 \\u0623\\u0634\\u0647\\u0631\"', 2000.00, 3, 'months', NULL, NULL, NULL, 1400.00, 3, 'months', '2025-12-17 08:06:02', '2025-12-17 08:06:02'),
(7, 6, 1, '\"\\u0627\\u0634\\u062a\\u0631\\u0627\\u0643 3 \\u0623\\u0634\\u0647\\u0631\"', 2000.00, 3, 'months', NULL, NULL, NULL, 1800.00, 3, 'months', '2025-12-17 08:09:00', '2025-12-17 08:09:00'),
(8, 7, 3, '\"\\u0643\\u0648\\u0644\\u0645\\u0646\"', 3400.00, 1, 'days', NULL, NULL, NULL, 1700.00, 31, 'days', '2025-12-17 08:55:05', '2025-12-17 08:55:05');

-- --------------------------------------------------------

--
-- بنية الجدول `payment_methods`
--

CREATE TABLE `payment_methods` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name_ar` varchar(100) NOT NULL,
  `name_en` varchar(100) NOT NULL,
  `code` varchar(30) DEFAULT NULL,
  `active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- إرجاع أو استيراد بيانات الجدول `payment_methods`
--

INSERT INTO `payment_methods` (`id`, `name_ar`, `name_en`, `code`, `active`, `created_at`, `updated_at`) VALUES
(1, 'نقدي', 'Cash', 'cash', 1, '2025-10-28 07:07:08', '2025-10-28 07:07:08'),
(2, 'بطاقة بنكية', 'Card', 'card', 1, '2025-10-28 07:07:08', '2025-10-28 07:07:08'),
(3, 'تحويل بنكي', 'Bank Transfer', 'bank', 1, '2025-10-28 07:07:08', '2025-10-28 07:07:08'),
(4, 'مدى', 'Mada', 'mada', 1, '2025-10-28 07:07:08', '2025-10-28 07:07:08'),
(5, 'Apple Pay', 'Apple Pay', 'apple', 1, '2025-10-28 07:07:08', '2025-10-28 07:07:08'),
(6, 'Google Pay', 'Google Pay', 'google', 1, '2025-10-28 07:07:08', '2025-10-28 07:07:08'),
(7, 'بطاقة إئتمانية', 'Credit Card', '7', 1, '2025-10-29 03:11:51', '2025-10-29 03:11:51');

-- --------------------------------------------------------

--
-- بنية الجدول `permissions`
--

CREATE TABLE `permissions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `guard_name` varchar(255) NOT NULL,
  `branch_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `permissions`
--

INSERT INTO `permissions` (`id`, `name`, `guard_name`, `branch_id`, `created_at`, `updated_at`) VALUES
(1, 'users.view', 'web', NULL, '2025-10-19 04:46:24', '2025-10-19 04:46:24'),
(2, 'users.create', 'web', NULL, '2025-10-19 04:46:24', '2025-10-19 04:46:24'),
(3, 'users.edit', 'web', NULL, '2025-10-19 04:46:24', '2025-10-19 04:46:24'),
(4, 'users.delete', 'web', NULL, '2025-10-19 04:46:24', '2025-10-19 04:46:24'),
(5, 'roles.view', 'web', NULL, '2025-10-19 04:46:24', '2025-10-19 04:46:24'),
(6, 'roles.create', 'web', NULL, '2025-10-19 04:46:24', '2025-10-19 04:46:24'),
(7, 'roles.edit', 'web', NULL, '2025-10-19 04:46:24', '2025-10-19 04:46:24'),
(8, 'roles.delete', 'web', NULL, '2025-10-19 04:46:24', '2025-10-19 04:46:24'),
(9, 'branches.view', 'web', NULL, '2025-10-19 04:46:24', '2025-10-19 04:46:24'),
(10, 'branches.create', 'web', NULL, '2025-10-19 04:46:24', '2025-10-19 04:46:24'),
(11, 'branches.edit', 'web', NULL, '2025-10-19 04:46:24', '2025-10-19 04:46:24'),
(12, 'branches.delete', 'web', NULL, '2025-10-19 04:46:24', '2025-10-19 04:46:24'),
(13, 'reports.view', 'web', NULL, '2025-10-19 04:46:25', '2025-10-19 04:46:25'),
(14, 'reports.export', 'web', NULL, '2025-10-19 04:46:25', '2025-10-19 04:46:25');

-- --------------------------------------------------------

--
-- بنية الجدول `roles`
--

CREATE TABLE `roles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) NOT NULL,
  `guard_name` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `roles`
--

INSERT INTO `roles` (`id`, `name`, `guard_name`, `created_at`, `updated_at`) VALUES
(1, 'super_admin', 'web', '2025-10-19 04:46:25', '2025-10-19 04:46:25');

-- --------------------------------------------------------

--
-- بنية الجدول `role_has_permissions`
--

CREATE TABLE `role_has_permissions` (
  `permission_id` bigint(20) UNSIGNED NOT NULL,
  `role_id` bigint(20) UNSIGNED NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `role_has_permissions`
--

INSERT INTO `role_has_permissions` (`permission_id`, `role_id`) VALUES
(1, 1),
(2, 1),
(3, 1),
(4, 1),
(5, 1),
(6, 1),
(7, 1),
(8, 1),
(9, 1),
(10, 1),
(11, 1),
(12, 1),
(13, 1),
(14, 1);

-- --------------------------------------------------------

--
-- بنية الجدول `services`
--

CREATE TABLE `services` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `service_code` varchar(10) DEFAULT NULL,
  `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`name`)),
  `service_category_id` bigint(20) UNSIGNED NOT NULL,
  `service_type_id` bigint(20) UNSIGNED NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `duration_value` int(10) UNSIGNED NOT NULL,
  `duration_unit` enum('days','months','years') NOT NULL,
  `start_time` time DEFAULT NULL,
  `end_time` time DEFAULT NULL,
  `notes` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`notes`)),
  `settings` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`settings`)),
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `services`
--

INSERT INTO `services` (`id`, `service_code`, `name`, `service_category_id`, `service_type_id`, `price`, `duration_value`, `duration_unit`, `start_time`, `end_time`, `notes`, `settings`, `active`, `created_at`, `updated_at`) VALUES
(1, '1001', '{\"ar\":\"اشتراك 3 أشهر\",\"en\":\"اشتراك 3 أشهر\"}', 1, 1, 2000.00, 3, 'months', '00:00:00', '12:00:00', '{\"en\":null}', '{\"pause\":{\"enabled\":\"1\",\"max_times\":\"3\",\"max_duration_value\":\"15\",\"max_duration_unit\":\"days\"},\"transfer\":{\"enabled\":\"1\",\"min_duration_value\":\"30\",\"min_duration_unit\":\"days\",\"fee\":\"100\"},\"refund\":{\"enabled\":\"1\",\"method\":\"money\"}}', 1, '2025-12-15 06:51:09', '2025-12-15 06:51:09'),
(2, '1002', '{\"ar\":\"اشتراك شهر 1\",\"en\":\"اشتراك شهر 1\"}', 1, 1, 2000.00, 1, 'months', '14:22:00', '14:22:00', '{\"en\":null}', NULL, 1, '2025-12-15 13:07:44', '2025-12-19 12:15:59'),
(3, '1003', '{\"ar\":\"كوامن\",\"en\":\"كولمن\"}', 2, 4, 3400.00, 1, 'days', '11:21:00', '07:30:00', '{\"en\":null}', '{\"pause\":{\"enabled\":\"1\",\"max_times\":\"3\",\"max_duration_value\":\"15\",\"max_duration_unit\":\"days\"},\"transfer\":{\"enabled\":\"1\",\"min_duration_value\":\"30\",\"min_duration_unit\":\"days\",\"fee\":\"500\"},\"renew\":{\"enabled\":\"1\",\"with_service_id\":\"2\",\"extra_duration_value\":\"15\",\"extra_duration_unit\":\"days\",\"max_duration_value\":\"3\",\"max_duration_unit\":\"months\"}}', 1, '2025-12-17 08:19:53', '2025-12-17 08:19:53'),
(4, '1004', '{\"ar\":\"سبونسر\",\"en\":\"سبونسر\"}', 4, 1, 0.00, 1, 'days', NULL, NULL, '{\"en\":null}', NULL, 1, '2025-12-17 10:49:57', '2025-12-17 10:49:57');

-- --------------------------------------------------------

--
-- بنية الجدول `service_categories`
--

CREATE TABLE `service_categories` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`name`)),
  `description` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`description`)),
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `service_categories`
--

INSERT INTO `service_categories` (`id`, `name`, `description`, `active`, `created_at`, `updated_at`) VALUES
(1, '{\"en\":\"العضويات\",\"ar\":\"العضويات\"}', '{\"ar\":null}', 1, '2025-12-15 06:49:14', '2025-12-15 06:49:14'),
(2, '{\"en\":\"اشتراك 6 شهور\",\"ar\":\"اشتراك 6 شهور\"}', '{\"en\":\"اشتراك 6 شهور\",\"ar\":\"اشتراك 6 شهور\"}', 1, '2025-12-16 08:21:01', '2025-12-16 08:21:01'),
(3, '{\"en\":\"اشتراك سنة\",\"ar\":\"اشتراك سنة\"}', '{\"en\":\"اشتراك سنة\",\"ar\":\"اشتراك سنة\"}', 1, '2025-12-16 08:21:55', '2025-12-16 08:21:55'),
(4, '{\"en\":\"اشتراك مجاني\",\"ar\":\"اشتراك مجاني\"}', '{\"ar\":null}', 1, '2025-12-17 08:28:43', '2025-12-17 08:28:43');

-- --------------------------------------------------------

--
-- بنية الجدول `service_invoices`
--

CREATE TABLE `service_invoices` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `document_no` bigint(20) UNSIGNED NOT NULL,
  `invoice_no` varchar(255) NOT NULL,
  `branch_id` bigint(20) UNSIGNED DEFAULT NULL,
  `member_id` bigint(20) UNSIGNED DEFAULT NULL,
  `provider_user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `service_user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `created_by` bigint(20) UNSIGNED DEFAULT NULL,
  `account_user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `greg_date` date NOT NULL,
  `hijri_date` varchar(255) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `payment_methods` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`payment_methods`)),
  `total_price` decimal(10,2) DEFAULT 0.00,
  `total_discount` decimal(10,2) DEFAULT 0.00,
  `total_tax` decimal(10,2) DEFAULT 0.00,
  `total_net` decimal(10,2) DEFAULT 0.00,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `service_invoices`
--

INSERT INTO `service_invoices` (`id`, `document_no`, `invoice_no`, `branch_id`, `member_id`, `provider_user_id`, `service_user_id`, `created_by`, `account_user_id`, `greg_date`, `hijri_date`, `notes`, `payment_methods`, `total_price`, `total_discount`, `total_tax`, `total_net`, `created_at`, `updated_at`) VALUES
(1, 1, 'SRV/2025I000001', 1, 1, 1, NULL, 1, 1, '2025-12-20', '29-6-1447', NULL, '[{\"method\":\"cash\",\"amount\":\"300.00\"},{\"method\":\"bank\",\"amount\":\"3610.00\"}]', 3400.00, 0.00, 510.00, 3910.00, '2025-12-20 03:09:23', '2025-12-20 03:09:23'),
(2, 2, 'SRV/2025I000002', 1, 2, 1, NULL, 1, 1, '2025-12-20', '29-6-1447', NULL, '[{\"method\":\"cash\",\"amount\":\"500.00\"},{\"method\":\"bank\",\"amount\":\"3410.00\"}]', 3400.00, 0.00, 510.00, 3910.00, '2025-12-20 03:11:39', '2025-12-20 03:11:39');

-- --------------------------------------------------------

--
-- بنية الجدول `service_invoice_items`
--

CREATE TABLE `service_invoice_items` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `service_invoice_id` bigint(20) UNSIGNED NOT NULL,
  `type` enum('service','offer') DEFAULT NULL,
  `service_id` bigint(20) UNSIGNED DEFAULT NULL,
  `offer_id` bigint(20) UNSIGNED DEFAULT NULL,
  `offer_service_id` bigint(20) UNSIGNED DEFAULT NULL,
  `description` varchar(255) DEFAULT NULL,
  `qty` int(10) UNSIGNED DEFAULT 1,
  `price` decimal(10,2) DEFAULT 0.00,
  `discount` decimal(10,2) DEFAULT 0.00,
  `tax` decimal(10,2) DEFAULT 0.00,
  `total` decimal(10,2) DEFAULT 0.00,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `service_invoice_items`
--

INSERT INTO `service_invoice_items` (`id`, `service_invoice_id`, `type`, `service_id`, `offer_id`, `offer_service_id`, `description`, `qty`, `price`, `discount`, `tax`, `total`, `created_at`, `updated_at`) VALUES
(1, 1, NULL, 3, NULL, NULL, 'كوامن', 1, 3400.00, 0.00, 510.00, 3910.00, '2025-12-20 03:09:23', '2025-12-20 03:09:23'),
(2, 2, NULL, 3, NULL, NULL, 'كوامن', 1, 3400.00, 0.00, 510.00, 3910.00, '2025-12-20 03:11:39', '2025-12-20 03:11:39');

-- --------------------------------------------------------

--
-- بنية الجدول `service_types`
--

CREATE TABLE `service_types` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`name`)),
  `description` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`description`)),
  `active` tinyint(1) NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `service_types`
--

INSERT INTO `service_types` (`id`, `name`, `description`, `active`, `created_at`, `updated_at`) VALUES
(1, '{\"en\":\"اشتراكات عامة\",\"ar\":\"اشتراكات عامة\"}', '{\"ar\":null}', 1, '2025-12-15 06:48:59', '2025-12-15 06:48:59'),
(2, '{\"en\":\"ايقاف مده اشتراك\",\"ar\":\"ايقاف مده اشتراك\"}', '{\"ar\":null}', 1, '2025-12-15 13:26:40', '2025-12-15 13:26:40'),
(3, '{\"en\":\"اشتركات خاصة\",\"ar\":\"اشتركات خاصة\"}', '{\"en\":\"اشتركات خاصة\",\"ar\":\"اشتركات خاصة\"}', 1, '2025-12-16 10:26:09', '2025-12-16 10:26:09'),
(4, '{\"en\":\"اشتركات مجانية\",\"ar\":\"اشتركات مجانية\"}', '{\"en\":\"اشتركات مجانية\",\"ar\":\"اشتركات مجانية\"}', 1, '2025-12-16 10:29:24', '2025-12-16 10:29:24');

-- --------------------------------------------------------

--
-- بنية الجدول `states`
--

CREATE TABLE `states` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NOT NULL CHECK (json_valid(`name`)),
  `country_id` bigint(20) UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- إرجاع أو استيراد بيانات الجدول `states`
--

INSERT INTO `states` (`id`, `name`, `country_id`, `created_at`, `updated_at`) VALUES
(1, '{\"ar\":\"القاهرة\",\"en\":\"Cairo\"}', 1, '2025-10-19 04:46:20', '2025-10-19 04:46:20'),
(2, '{\"ar\":\"الإسكندرية\",\"en\":\"Alexandria\"}', 1, '2025-10-19 04:46:20', '2025-10-19 04:46:20'),
(3, '{\"ar\":\"الجيزة\",\"en\":\"Giza\"}', 1, '2025-10-19 04:46:20', '2025-10-19 04:46:20'),
(4, '{\"ar\":\"الرياض\",\"en\":\"Riyadh\"}', 2, '2025-10-19 04:46:20', '2025-10-19 04:46:20'),
(5, '{\"ar\":\"جدة\",\"en\":\"Jeddah\"}', 2, '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(6, '{\"ar\":\"مكة\",\"en\":\"Mecca\"}', 2, '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(7, '{\"ar\":\"دبي\",\"en\":\"Dubai\"}', 3, '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(8, '{\"ar\":\"أبوظبي\",\"en\":\"Abu Dhabi\"}', 3, '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(9, '{\"ar\":\"الشارقة\",\"en\":\"Sharjah\"}', 3, '2025-10-19 04:46:21', '2025-10-19 04:46:21'),
(10, '{\"ar\":\"مسقط\",\"en\":\"Muscat\"}', 11, '2025-10-19 04:46:22', '2025-10-19 04:46:22'),
(11, '{\"ar\":\"ظفار\",\"en\":\"Dhofar\"}', 11, '2025-10-19 04:46:22', '2025-10-19 04:46:22'),
(12, '{\"ar\":\"الباطنة شمال\",\"en\":\"North Batinah\"}', 11, '2025-10-19 04:46:22', '2025-10-19 04:46:22'),
(13, '{\"ar\":\"الدوحة\",\"en\":\"Doha\"}', 12, '2025-10-19 04:46:22', '2025-10-19 04:46:22'),
(14, '{\"ar\":\"الريان\",\"en\":\"Al Rayyan\"}', 12, '2025-10-19 04:46:22', '2025-10-19 04:46:22'),
(15, '{\"ar\":\"الخور\",\"en\":\"Al Khor\"}', 12, '2025-10-19 04:46:23', '2025-10-19 04:46:23'),
(16, '{\"ar\":\"المنامة\",\"en\":\"Manama\"}', 13, '2025-10-19 04:46:23', '2025-10-19 04:46:23'),
(17, '{\"ar\":\"المحرق\",\"en\":\"Muharraq\"}', 13, '2025-10-19 04:46:23', '2025-10-19 04:46:23'),
(18, '{\"ar\":\"رام الله\",\"en\":\"Ramallah\"}', 14, '2025-10-19 04:46:23', '2025-10-19 04:46:23'),
(19, '{\"ar\":\"غزة\",\"en\":\"Gaza\"}', 14, '2025-10-19 04:46:23', '2025-10-19 04:46:23'),
(20, '{\"ar\":\"دمشق\",\"en\":\"Damascus\"}', 15, '2025-10-19 04:46:23', '2025-10-19 04:46:23'),
(21, '{\"ar\":\"حلب\",\"en\":\"Aleppo\"}', 15, '2025-10-19 04:46:23', '2025-10-19 04:46:23'),
(22, '{\"ar\":\"صنعاء\",\"en\":\"Sanaa\"}', 16, '2025-10-19 04:46:23', '2025-10-19 04:46:23'),
(23, '{\"ar\":\"عدن\",\"en\":\"Aden\"}', 16, '2025-10-19 04:46:23', '2025-10-19 04:46:23');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `branches`
--
ALTER TABLE `branches`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `branches_branch_code_unique` (`branch_code`),
  ADD KEY `branches_branch_category_id_foreign` (`branch_category_id`),
  ADD KEY `branches_branch_type_id_foreign` (`branch_type_id`),
  ADD KEY `branches_city_id_foreign` (`city_id`);

--
-- Indexes for table `branch_categories`
--
ALTER TABLE `branch_categories`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `branch_monthly_goals`
--
ALTER TABLE `branch_monthly_goals`
  ADD PRIMARY KEY (`id`),
  ADD KEY `branch_monthly_goals_branch_id_foreign` (`branch_id`);

--
-- Indexes for table `branch_service_provided`
--
ALTER TABLE `branch_service_provided`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `branch_service_provided_service_id_branch_id_unique` (`service_id`,`branch_id`),
  ADD KEY `branch_service_provided_branch_id_foreign` (`branch_id`);

--
-- Indexes for table `branch_service_sold`
--
ALTER TABLE `branch_service_sold`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `branch_service_sold_service_id_branch_id_unique` (`service_id`,`branch_id`),
  ADD KEY `branch_service_sold_branch_id_foreign` (`branch_id`);

--
-- Indexes for table `branch_types`
--
ALTER TABLE `branch_types`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `cities`
--
ALTER TABLE `cities`
  ADD PRIMARY KEY (`id`),
  ADD KEY `cities_state_id_foreign` (`state_id`);

--
-- Indexes for table `company_settings`
--
ALTER TABLE `company_settings`
  ADD PRIMARY KEY (`id`),
  ADD KEY `company_settings_country_id_foreign` (`country_id`);

--
-- Indexes for table `countries`
--
ALTER TABLE `countries`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `customers`
--
ALTER TABLE `customers`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `customers_customer_code_unique` (`customer_code`),
  ADD KEY `customers_branch_id_foreign` (`branch_id`);

--
-- Indexes for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);

--
-- Indexes for table `members`
--
ALTER TABLE `members`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `members_member_code_unique` (`member_code`),
  ADD UNIQUE KEY `members_id_number_unique` (`id_number`),
  ADD KEY `members_nationality_id_foreign` (`nationality_id`),
  ADD KEY `members_branch_id_status_index` (`branch_id`,`status`);

--
-- Indexes for table `member_sequences`
--
ALTER TABLE `member_sequences`
  ADD PRIMARY KEY (`branch_id`);

--
-- Indexes for table `migrations`
--
ALTER TABLE `migrations`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `model_has_permissions`
--
ALTER TABLE `model_has_permissions`
  ADD PRIMARY KEY (`permission_id`,`model_id`,`model_type`),
  ADD KEY `model_has_permissions_model_id_model_type_index` (`model_id`,`model_type`);

--
-- Indexes for table `model_has_roles`
--
ALTER TABLE `model_has_roles`
  ADD PRIMARY KEY (`role_id`,`model_id`,`model_type`),
  ADD KEY `model_has_roles_model_id_model_type_index` (`model_id`,`model_type`);

--
-- Indexes for table `offers`
--
ALTER TABLE `offers`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `offers_offer_no_unique` (`offer_no`);

--
-- Indexes for table `offer_items`
--
ALTER TABLE `offer_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `offer_items_offer_id_foreign` (`offer_id`),
  ADD KEY `offer_items_service_id_foreign` (`service_id`);

--
-- Indexes for table `payment_methods`
--
ALTER TABLE `payment_methods`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `code` (`code`);

--
-- Indexes for table `permissions`
--
ALTER TABLE `permissions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `perm_name_guard_branch_unique` (`name`,`guard_name`,`branch_id`),
  ADD KEY `permissions_branch_id_foreign` (`branch_id`);

--
-- Indexes for table `roles`
--
ALTER TABLE `roles`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `roles_name_guard_name_unique` (`name`,`guard_name`);

--
-- Indexes for table `role_has_permissions`
--
ALTER TABLE `role_has_permissions`
  ADD PRIMARY KEY (`permission_id`,`role_id`),
  ADD KEY `role_has_permissions_role_id_foreign` (`role_id`);

--
-- Indexes for table `services`
--
ALTER TABLE `services`
  ADD PRIMARY KEY (`id`),
  ADD KEY `services_service_category_id_foreign` (`service_category_id`),
  ADD KEY `services_service_type_id_foreign` (`service_type_id`);

--
-- Indexes for table `service_categories`
--
ALTER TABLE `service_categories`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `service_invoices`
--
ALTER TABLE `service_invoices`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `document_no` (`document_no`),
  ADD UNIQUE KEY `invoice_no` (`invoice_no`),
  ADD KEY `service_invoices_branch_id_foreign` (`branch_id`),
  ADD KEY `service_invoices_member_id_foreign` (`member_id`),
  ADD KEY `service_invoices_provider_id_foreign` (`provider_user_id`),
  ADD KEY `service_invoices_service_user_id_foreign` (`service_user_id`),
  ADD KEY `service_invoices_created_by_foreign` (`created_by`),
  ADD KEY `service_invoices_account_user_id_foreign` (`account_user_id`);

--
-- Indexes for table `service_invoice_items`
--
ALTER TABLE `service_invoice_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `invoice_items_invoice_id_fk` (`service_invoice_id`),
  ADD KEY `invoice_items_service_id_fk` (`service_id`),
  ADD KEY `invoice_items_offer_id_fk` (`offer_id`);

--
-- Indexes for table `service_types`
--
ALTER TABLE `service_types`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `states`
--
ALTER TABLE `states`
  ADD PRIMARY KEY (`id`),
  ADD KEY `states_country_id_foreign` (`country_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `branches`
--
ALTER TABLE `branches`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `branch_categories`
--
ALTER TABLE `branch_categories`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `branch_monthly_goals`
--
ALTER TABLE `branch_monthly_goals`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `branch_service_provided`
--
ALTER TABLE `branch_service_provided`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `branch_service_sold`
--
ALTER TABLE `branch_service_sold`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `branch_types`
--
ALTER TABLE `branch_types`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `cities`
--
ALTER TABLE `cities`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `company_settings`
--
ALTER TABLE `company_settings`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `countries`
--
ALTER TABLE `countries`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;

--
-- AUTO_INCREMENT for table `customers`
--
ALTER TABLE `customers`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

--
-- AUTO_INCREMENT for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `members`
--
ALTER TABLE `members`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;

--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=23;

--
-- AUTO_INCREMENT for table `offers`
--
ALTER TABLE `offers`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `offer_items`
--
ALTER TABLE `offer_items`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

--
-- AUTO_INCREMENT for table `payment_methods`
--
ALTER TABLE `payment_methods`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

--
-- AUTO_INCREMENT for table `permissions`
--
ALTER TABLE `permissions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;

--
-- AUTO_INCREMENT for table `roles`
--
ALTER TABLE `roles`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `services`
--
ALTER TABLE `services`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `service_categories`
--
ALTER TABLE `service_categories`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `service_invoices`
--
ALTER TABLE `service_invoices`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `service_invoice_items`
--
ALTER TABLE `service_invoice_items`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `service_types`
--
ALTER TABLE `service_types`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `states`
--
ALTER TABLE `states`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;

--
-- قيود الجداول المُلقاة.
--

--
-- قيود الجداول `branches`
--
ALTER TABLE `branches`
  ADD CONSTRAINT `branches_branch_category_id_foreign` FOREIGN KEY (`branch_category_id`) REFERENCES `branch_categories` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `branches_branch_type_id_foreign` FOREIGN KEY (`branch_type_id`) REFERENCES `branch_types` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `branches_city_id_foreign` FOREIGN KEY (`city_id`) REFERENCES `states` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `branch_monthly_goals`
--
ALTER TABLE `branch_monthly_goals`
  ADD CONSTRAINT `branch_monthly_goals_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `branch_service_provided`
--
ALTER TABLE `branch_service_provided`
  ADD CONSTRAINT `branch_service_provided_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `branch_service_provided_service_id_foreign` FOREIGN KEY (`service_id`) REFERENCES `services` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `branch_service_sold`
--
ALTER TABLE `branch_service_sold`
  ADD CONSTRAINT `branch_service_sold_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `branch_service_sold_service_id_foreign` FOREIGN KEY (`service_id`) REFERENCES `services` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `cities`
--
ALTER TABLE `cities`
  ADD CONSTRAINT `cities_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `states` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `company_settings`
--
ALTER TABLE `company_settings`
  ADD CONSTRAINT `company_settings_country_id_foreign` FOREIGN KEY (`country_id`) REFERENCES `countries` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `customers`
--
ALTER TABLE `customers`
  ADD CONSTRAINT `customers_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `members`
--
ALTER TABLE `members`
  ADD CONSTRAINT `members_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `members_nationality_id_foreign` FOREIGN KEY (`nationality_id`) REFERENCES `countries` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `member_sequences`
--
ALTER TABLE `member_sequences`
  ADD CONSTRAINT `member_sequences_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `model_has_permissions`
--
ALTER TABLE `model_has_permissions`
  ADD CONSTRAINT `model_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `model_has_roles`
--
ALTER TABLE `model_has_roles`
  ADD CONSTRAINT `model_has_roles_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `offer_items`
--
ALTER TABLE `offer_items`
  ADD CONSTRAINT `offer_items_offer_id_foreign` FOREIGN KEY (`offer_id`) REFERENCES `offers` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `offer_items_service_id_foreign` FOREIGN KEY (`service_id`) REFERENCES `services` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `permissions`
--
ALTER TABLE `permissions`
  ADD CONSTRAINT `permissions_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `role_has_permissions`
--
ALTER TABLE `role_has_permissions`
  ADD CONSTRAINT `role_has_permissions_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `role_has_permissions_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `services`
--
ALTER TABLE `services`
  ADD CONSTRAINT `services_service_category_id_foreign` FOREIGN KEY (`service_category_id`) REFERENCES `service_categories` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `services_service_type_id_foreign` FOREIGN KEY (`service_type_id`) REFERENCES `service_types` (`id`) ON DELETE CASCADE;

--
-- قيود الجداول `service_invoices`
--
ALTER TABLE `service_invoices`
  ADD CONSTRAINT `service_invoices_account_user_id_foreign` FOREIGN KEY (`account_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `service_invoices_branch_id_foreign` FOREIGN KEY (`branch_id`) REFERENCES `branches` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `service_invoices_created_by_foreign` FOREIGN KEY (`created_by`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `service_invoices_member_id_foreign` FOREIGN KEY (`member_id`) REFERENCES `members` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `service_invoices_provider_id_foreign` FOREIGN KEY (`provider_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `service_invoices_service_user_id_foreign` FOREIGN KEY (`service_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `service_invoice_items`
--
ALTER TABLE `service_invoice_items`
  ADD CONSTRAINT `invoice_items_invoice_id_fk` FOREIGN KEY (`service_invoice_id`) REFERENCES `service_invoices` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `invoice_items_offer_id_fk` FOREIGN KEY (`offer_id`) REFERENCES `offers` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `invoice_items_service_id_fk` FOREIGN KEY (`service_id`) REFERENCES `services` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `states`
--
ALTER TABLE `states`
  ADD CONSTRAINT `states_country_id_foreign` FOREIGN KEY (`country_id`) REFERENCES `countries` (`id`) ON DELETE CASCADE;
COMMIT;

