-- phpMyAdmin SQL Dump
-- version 5.2.3
-- https://www.phpmyadmin.net/
--
-- Host: localhost:3306
-- Generation Time: Aug 16, 2026 at 07:57 PM
-- Server version: 10.11.18-MariaDB-cll-lve
-- PHP Version: 8.4.24

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `mytoolsh_ashokdata`
--

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

--
-- Table structure for table `activity_logs`
--

CREATE TABLE `activity_logs` (
  `id` int(10) UNSIGNED NOT NULL,
  `actor_type` enum('admin','user','system') NOT NULL DEFAULT 'admin',
  `actor_id` int(10) UNSIGNED DEFAULT NULL,
  `action` varchar(150) NOT NULL,
  `module` varchar(100) DEFAULT NULL,
  `reference_id` int(10) UNSIGNED DEFAULT NULL,
  `description` text DEFAULT NULL,
  `ip_address` varchar(45) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `activity_logs`
--

INSERT INTO `activity_logs` (`id`, `actor_type`, `actor_id`, `action`, `module`, `reference_id`, `description`, `ip_address`, `created_at`) VALUES
(1, 'admin', 1, 'login', 'auth', NULL, 'Admin logged in', '152.59.144.49', '2026-08-09 17:11:39'),
(2, 'admin', 1, 'login', 'auth', NULL, 'Admin logged in', '122.168.90.104', '2026-08-09 17:18:25'),
(3, 'admin', 1, 'login', 'auth', NULL, 'Admin logged in', '122.168.90.104', '2026-08-09 19:58:04'),
(4, 'admin', 1, 'login', 'auth', NULL, 'Admin logged in', '106.219.72.104', '2026-08-14 00:19:43'),
(5, 'admin', 1, 'login', 'auth', NULL, 'Admin logged in', '152.59.147.168', '2026-08-16 07:49:19'),
(6, 'admin', 1, 'login', 'auth', NULL, 'Admin logged in', '223.184.142.19', '2026-08-16 08:33:29'),
(7, 'admin', 1, 'send', 'notifications', NULL, 'Sent notification: Hhhhh (target: all)', '223.184.142.19', '2026-08-16 08:33:56'),
(8, 'admin', 1, 'login', 'auth', NULL, 'Admin logged in', '152.59.147.168', '2026-08-16 13:11:56'),
(9, 'admin', 1, 'update', 'categories', 1, 'Updated category: GPS Vehicle Tracking', '152.59.147.168', '2026-08-16 13:12:14'),
(10, 'admin', 1, 'update', 'settings', NULL, 'Updated app settings', '152.59.147.168', '2026-08-16 13:23:18'),
(11, 'admin', 1, 'reply', 'support', 1, 'Ticket #1 updated to open', '152.59.147.168', '2026-08-16 13:24:38'),
(12, 'admin', 1, 'reply', 'support', 1, 'Ticket #1 updated to open', '152.59.147.168', '2026-08-16 13:24:42'),
(13, 'admin', 1, 'reply', 'support', 1, 'Ticket #1 updated to open', '152.59.147.168', '2026-08-16 13:24:46'),
(14, 'admin', 1, 'login', 'auth', NULL, 'Admin logged in', '122.183.39.178', '2026-08-16 13:53:54'),
(15, 'admin', 1, 'send', 'notifications', NULL, 'Sent notification: gps offer (target: all)', '122.183.39.178', '2026-08-16 13:58:27'),
(16, 'admin', 1, 'send', 'notifications', NULL, 'Sent notification: kjkkjkj (target: selected)', '122.183.39.178', '2026-08-16 14:00:14'),
(17, 'admin', 1, 'update', 'settings', NULL, 'Updated app settings', '152.59.147.168', '2026-08-16 14:23:35'),
(18, 'admin', 1, 'update', 'settings', NULL, 'Updated app settings', '122.183.39.178', '2026-08-16 14:38:18'),
(19, 'admin', 1, 'update', 'settings', NULL, 'Updated app settings', '122.183.39.178', '2026-08-16 14:53:54');

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

--
-- Table structure for table `admins`
--

CREATE TABLE `admins` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(150) NOT NULL,
  `email` varchar(150) NOT NULL,
  `password` varchar(255) NOT NULL,
  `role` enum('superadmin','admin','staff') NOT NULL DEFAULT 'admin',
  `status` enum('active','blocked') NOT NULL DEFAULT 'active',
  `last_login_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `admins`
--

INSERT INTO `admins` (`id`, `name`, `email`, `password`, `role`, `status`, `last_login_at`, `created_at`, `updated_at`) VALUES
(1, 'Super Admin', 'admin@ashokservices.com', '$2y$10$059EuZq0Vwo19FS.6jDcPOCIJPcbKmCG.OEEl/DoGOiJJuTYqdobO', 'superadmin', 'active', '2026-08-16 13:53:54', '2026-08-09 17:11:06', '2026-08-16 13:53:54');

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

--
-- Table structure for table `banners`
--

CREATE TABLE `banners` (
  `id` int(10) UNSIGNED NOT NULL,
  `title` varchar(200) DEFAULT NULL,
  `image` varchar(255) NOT NULL,
  `link_type` varchar(50) DEFAULT NULL,
  `link_value` varchar(255) DEFAULT NULL,
  `sort_order` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `bus_requests`
--

CREATE TABLE `bus_requests` (
  `id` int(10) UNSIGNED NOT NULL,
  `request_code` varchar(30) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `from_city` varchar(100) NOT NULL,
  `to_city` varchar(100) NOT NULL,
  `journey_date` date NOT NULL,
  `passenger_count` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `passenger_details` text DEFAULT NULL,
  `contact_number` varchar(15) NOT NULL,
  `status` enum('pending','under_review','processing','completed','cancelled') NOT NULL DEFAULT 'pending',
  `admin_notes` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `categories`
--

CREATE TABLE `categories` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(150) NOT NULL,
  `slug` varchar(170) NOT NULL,
  `icon` varchar(255) DEFAULT NULL,
  `description` varchar(500) DEFAULT NULL,
  `sort_order` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` (`id`, `name`, `slug`, `icon`, `description`, `sort_order`, `status`, `created_at`, `updated_at`) VALUES
(1, 'GPS Vehicle Tracking', 'gps-vehicle-tracking', NULL, 'vgffg', 1, 'active', '2026-08-09 17:11:06', '2026-08-16 13:12:14'),
(2, 'Flight Ticket', 'flight-ticket', NULL, NULL, 2, 'active', '2026-08-09 17:11:06', '2026-08-09 17:11:06'),
(3, 'Vehicle Insurance', 'vehicle-insurance', NULL, NULL, 3, 'active', '2026-08-09 17:11:06', '2026-08-09 17:11:06'),
(4, 'Government & Digital Services', 'government-digital-services', NULL, NULL, 4, 'active', '2026-08-09 17:11:06', '2026-08-09 17:11:06'),
(5, 'Vehicle Services', 'vehicle-services', NULL, NULL, 5, 'active', '2026-08-09 17:11:06', '2026-08-09 17:11:06'),
(6, 'Train/Bus Booking', 'train-bus-booking', NULL, NULL, 6, 'active', '2026-08-09 17:11:06', '2026-08-09 17:11:06'),
(7, 'Taxi & Tour', 'taxi-tour', NULL, NULL, 7, 'active', '2026-08-09 17:11:06', '2026-08-09 17:11:06'),
(8, 'Document Services', 'document-services', NULL, NULL, 8, 'active', '2026-08-09 17:11:06', '2026-08-09 17:11:06');

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

--
-- Table structure for table `documents`
--

CREATE TABLE `documents` (
  `id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `owner_type` enum('service_request','insurance_request','vehicle','profile') NOT NULL,
  `owner_id` int(10) UNSIGNED DEFAULT NULL,
  `doc_type` varchar(100) DEFAULT NULL,
  `file_path` varchar(255) NOT NULL,
  `file_name` varchar(255) DEFAULT NULL,
  `file_size` int(10) UNSIGNED DEFAULT NULL,
  `mime_type` varchar(100) DEFAULT NULL,
  `uploaded_by` enum('user','admin') NOT NULL DEFAULT 'user',
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `flight_requests`
--

CREATE TABLE `flight_requests` (
  `id` int(10) UNSIGNED NOT NULL,
  `request_code` varchar(30) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `from_city` varchar(100) NOT NULL,
  `to_city` varchar(100) NOT NULL,
  `journey_date` date NOT NULL,
  `passenger_count` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `passenger_details` text DEFAULT NULL COMMENT 'JSON array',
  `contact_number` varchar(15) NOT NULL,
  `status` enum('pending','under_review','processing','completed','cancelled') NOT NULL DEFAULT 'pending',
  `admin_notes` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `gps_devices`
--

CREATE TABLE `gps_devices` (
  `id` int(10) UNSIGNED NOT NULL,
  `device_imei` varchar(50) NOT NULL,
  `sim_number` varchar(20) DEFAULT NULL,
  `device_model` varchar(100) DEFAULT NULL,
  `status` enum('unassigned','assigned','inactive') NOT NULL DEFAULT 'unassigned',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `gps_locations`
--

CREATE TABLE `gps_locations` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `vehicle_id` int(10) UNSIGNED NOT NULL,
  `latitude` decimal(10,7) NOT NULL,
  `longitude` decimal(10,7) NOT NULL,
  `speed` decimal(6,2) DEFAULT 0.00,
  `is_online` tinyint(1) NOT NULL DEFAULT 1,
  `recorded_at` datetime NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `insurance_requests`
--

CREATE TABLE `insurance_requests` (
  `id` int(10) UNSIGNED NOT NULL,
  `request_code` varchar(30) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `insurance_type` enum('car','bike') NOT NULL,
  `vehicle_number` varchar(20) NOT NULL,
  `vehicle_model` varchar(150) DEFAULT NULL,
  `previous_policy_number` varchar(100) DEFAULT NULL,
  `status` enum('pending','processing','completed','rejected') NOT NULL DEFAULT 'pending',
  `policy_document` varchar(255) DEFAULT NULL,
  `admin_notes` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `insurance_requests`
--

INSERT INTO `insurance_requests` (`id`, `request_code`, `user_id`, `insurance_type`, `vehicle_number`, `vehicle_model`, `previous_policy_number`, `status`, `policy_document`, `admin_notes`, `created_at`, `updated_at`) VALUES
(1, 'INS-20260816-B89166', 2, 'car', '6YYY', 'gttt', NULL, 'pending', NULL, NULL, '2026-08-16 13:56:02', '2026-08-16 13:56:02');

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

--
-- Table structure for table `notifications`
--

CREATE TABLE `notifications` (
  `id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED DEFAULT NULL COMMENT 'NULL = broadcast to all',
  `title` varchar(200) NOT NULL,
  `message` text NOT NULL,
  `type` enum('application','payment','document','booking','offer','general') NOT NULL DEFAULT 'general',
  `reference_type` varchar(50) DEFAULT NULL,
  `reference_id` int(10) UNSIGNED DEFAULT NULL,
  `is_read` tinyint(1) NOT NULL DEFAULT 0,
  `sent_by_admin_id` int(10) UNSIGNED DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `notifications`
--

INSERT INTO `notifications` (`id`, `user_id`, `title`, `message`, `type`, `reference_type`, `reference_id`, `is_read`, `sent_by_admin_id`, `created_at`) VALUES
(1, NULL, 'Hhhhh', 'Hhhh', 'offer', NULL, NULL, 0, 1, '2026-08-16 08:33:56'),
(2, 1, 'Reply to your support ticket TKT-20260816-218226', 'done', 'general', 'support_ticket', 1, 0, 1, '2026-08-16 13:24:38'),
(3, 1, 'Reply to your support ticket TKT-20260816-218226', 'bgftf', 'general', 'support_ticket', 1, 0, 1, '2026-08-16 13:24:46'),
(4, NULL, 'gps offer', 'book', 'offer', NULL, NULL, 0, 1, '2026-08-16 13:58:27'),
(5, 2, 'kjkkjkj', 'jijh', 'general', NULL, NULL, 0, 1, '2026-08-16 14:00:14');

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

--
-- Table structure for table `offers`
--

CREATE TABLE `offers` (
  `id` int(10) UNSIGNED NOT NULL,
  `title` varchar(200) NOT NULL,
  `description` varchar(500) DEFAULT NULL,
  `code` varchar(50) DEFAULT NULL,
  `discount_type` enum('flat','percent') NOT NULL DEFAULT 'flat',
  `discount_value` decimal(10,2) NOT NULL DEFAULT 0.00,
  `valid_from` date DEFAULT NULL,
  `valid_till` date DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `otp_requests`
--

CREATE TABLE `otp_requests` (
  `id` int(10) UNSIGNED NOT NULL,
  `mobile` varchar(15) NOT NULL,
  `otp` varchar(10) NOT NULL,
  `purpose` enum('login','register') NOT NULL DEFAULT 'login',
  `is_used` tinyint(1) NOT NULL DEFAULT 0,
  `expires_at` datetime NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `otp_requests`
--

INSERT INTO `otp_requests` (`id`, `mobile`, `otp`, `purpose`, `is_used`, `expires_at`, `created_at`) VALUES
(1, '7209891746', '510013', 'register', 1, '2026-08-16 13:15:29', '2026-08-16 13:10:29'),
(2, '8436641402', '624600', 'register', 1, '2026-08-16 13:47:36', '2026-08-16 13:42:36');

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

--
-- Table structure for table `payments`
--

CREATE TABLE `payments` (
  `id` int(10) UNSIGNED NOT NULL,
  `transaction_id` varchar(100) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `owner_type` enum('service_request','flight_request','train_request','bus_request','taxi_request','insurance_request') NOT NULL,
  `owner_id` int(10) UNSIGNED NOT NULL,
  `amount` decimal(10,2) NOT NULL,
  `gateway` varchar(50) DEFAULT NULL,
  `gateway_payment_id` varchar(150) DEFAULT NULL,
  `status` enum('pending','successful','failed','refunded') NOT NULL DEFAULT 'pending',
  `refund_status` enum('none','requested','processed') NOT NULL DEFAULT 'none',
  `receipt_path` varchar(255) DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `services`
--

CREATE TABLE `services` (
  `id` int(10) UNSIGNED NOT NULL,
  `category_id` int(10) UNSIGNED NOT NULL,
  `name` varchar(200) NOT NULL,
  `slug` varchar(220) NOT NULL,
  `image` varchar(255) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `price` decimal(10,2) NOT NULL DEFAULT 0.00,
  `discount_price` decimal(10,2) DEFAULT NULL,
  `required_documents` text DEFAULT NULL COMMENT 'JSON array of document names',
  `processing_time` varchar(100) DEFAULT NULL,
  `form_fields` text DEFAULT NULL COMMENT 'JSON schema for dynamic form',
  `sort_order` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `service_forms`
--

CREATE TABLE `service_forms` (
  `id` int(10) UNSIGNED NOT NULL,
  `service_request_id` int(10) UNSIGNED NOT NULL,
  `field_key` varchar(150) NOT NULL,
  `field_label` varchar(200) DEFAULT NULL,
  `field_value` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `service_requests`
--

CREATE TABLE `service_requests` (
  `id` int(10) UNSIGNED NOT NULL,
  `request_code` varchar(30) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `service_id` int(10) UNSIGNED NOT NULL,
  `status` enum('pending','under_review','documents_required','processing','completed','rejected','cancelled') NOT NULL DEFAULT 'pending',
  `amount` decimal(10,2) NOT NULL DEFAULT 0.00,
  `admin_notes` text DEFAULT NULL,
  `rejection_reason` varchar(500) DEFAULT NULL,
  `final_document` varchar(255) DEFAULT NULL,
  `assigned_admin_id` int(10) UNSIGNED DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `settings`
--

CREATE TABLE `settings` (
  `id` int(10) UNSIGNED NOT NULL,
  `setting_key` varchar(100) NOT NULL,
  `setting_value` text DEFAULT NULL,
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `settings`
--

INSERT INTO `settings` (`id`, `setting_key`, `setting_value`, `updated_at`) VALUES
(1, 'app_name', 'Ashok Services', '2026-08-16 14:53:54'),
(2, 'app_logo', 'settings/f_6a8181aa087851.58500420.png', '2026-08-16 14:53:54'),
(3, 'contact_number', '9832331602', '2026-08-16 14:53:54'),
(4, 'whatsapp_number', '9832331602', '2026-08-16 14:53:54'),
(5, 'support_email', 'secure9832331602@gmail.com', '2026-08-16 14:53:54'),
(6, 'privacy_policy', '', '2026-08-16 14:53:54'),
(7, 'terms_conditions', '', '2026-08-16 14:53:54'),
(8, 'payment_gateway', 'razorpay', '2026-08-16 14:53:54'),
(9, 'payment_key_id', '', '2026-08-16 14:53:54'),
(10, 'payment_key_secret', '', '2026-08-16 14:53:54'),
(11, 'otp_expiry_minutes', '5', '2026-08-16 14:53:54');

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

--
-- Table structure for table `support_tickets`
--

CREATE TABLE `support_tickets` (
  `id` int(10) UNSIGNED NOT NULL,
  `ticket_code` varchar(30) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `subject` varchar(200) NOT NULL,
  `message` text NOT NULL,
  `status` enum('open','in_progress','resolved','closed') NOT NULL DEFAULT 'open',
  `admin_reply` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `support_tickets`
--

INSERT INTO `support_tickets` (`id`, `ticket_code`, `user_id`, `subject`, `message`, `status`, `admin_reply`, `created_at`, `updated_at`) VALUES
(1, 'TKT-20260816-218226', 1, 'Hi Cheak', 'demo cheak', 'open', 'bgftf', '2026-08-16 13:24:20', '2026-08-16 13:24:46');

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

--
-- Table structure for table `taxi_requests`
--

CREATE TABLE `taxi_requests` (
  `id` int(10) UNSIGNED NOT NULL,
  `request_code` varchar(30) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `pickup_location` varchar(255) NOT NULL,
  `drop_location` varchar(255) NOT NULL,
  `journey_datetime` datetime NOT NULL,
  `vehicle_type` varchar(50) DEFAULT NULL,
  `contact_number` varchar(15) NOT NULL,
  `status` enum('pending','under_review','processing','completed','cancelled') NOT NULL DEFAULT 'pending',
  `admin_notes` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `tour_packages`
--

CREATE TABLE `tour_packages` (
  `id` int(10) UNSIGNED NOT NULL,
  `name` varchar(200) NOT NULL,
  `image` varchar(255) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `duration` varchar(100) DEFAULT NULL,
  `price` decimal(10,2) NOT NULL DEFAULT 0.00,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `tour_requests`
--

CREATE TABLE `tour_requests` (
  `id` int(10) UNSIGNED NOT NULL,
  `request_code` varchar(30) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `tour_package_id` int(10) UNSIGNED NOT NULL,
  `travel_date` date NOT NULL,
  `traveler_count` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `contact_number` varchar(15) NOT NULL,
  `status` enum('pending','under_review','processing','completed','cancelled') NOT NULL DEFAULT 'pending',
  `admin_notes` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `train_requests`
--

CREATE TABLE `train_requests` (
  `id` int(10) UNSIGNED NOT NULL,
  `request_code` varchar(30) NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `from_city` varchar(100) NOT NULL,
  `to_city` varchar(100) NOT NULL,
  `journey_date` date NOT NULL,
  `passenger_count` int(10) UNSIGNED NOT NULL DEFAULT 1,
  `passenger_details` text DEFAULT NULL,
  `contact_number` varchar(15) NOT NULL,
  `status` enum('pending','under_review','processing','completed','cancelled') NOT NULL DEFAULT 'pending',
  `admin_notes` text DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(10) UNSIGNED NOT NULL,
  `mobile` varchar(15) NOT NULL,
  `name` varchar(150) DEFAULT NULL,
  `email` varchar(150) DEFAULT NULL,
  `address` text DEFAULT NULL,
  `city` varchar(100) DEFAULT NULL,
  `state` varchar(100) DEFAULT NULL,
  `pincode` varchar(10) DEFAULT NULL,
  `profile_image` varchar(255) DEFAULT NULL,
  `fcm_token` varchar(255) DEFAULT NULL,
  `status` enum('active','blocked') NOT NULL DEFAULT 'active',
  `is_verified` tinyint(1) NOT NULL DEFAULT 0,
  `last_login_at` datetime DEFAULT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `mobile`, `name`, `email`, `address`, `city`, `state`, `pincode`, `profile_image`, `fcm_token`, `status`, `is_verified`, `last_login_at`, `created_at`, `updated_at`) VALUES
(1, '7209891746', 'Samir Kumar', 'samirgupta1541@gmail.com', NULL, NULL, NULL, NULL, NULL, NULL, 'active', 1, '2026-08-16 13:10:31', '2026-08-16 13:10:31', '2026-08-16 13:10:44'),
(2, '8436641402', 'Rajaja', NULL, NULL, NULL, NULL, NULL, NULL, NULL, 'active', 1, '2026-08-16 13:42:44', '2026-08-16 13:42:44', '2026-08-16 13:42:54');

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

--
-- Table structure for table `vehicles`
--

CREATE TABLE `vehicles` (
  `id` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `gps_device_id` int(10) UNSIGNED DEFAULT NULL,
  `vehicle_number` varchar(20) NOT NULL,
  `vehicle_name` varchar(150) DEFAULT NULL,
  `vehicle_type` varchar(50) DEFAULT NULL,
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `vehicles`
--

INSERT INTO `vehicles` (`id`, `user_id`, `gps_device_id`, `vehicle_number`, `vehicle_name`, `vehicle_type`, `status`, `created_at`, `updated_at`) VALUES
(1, 2, NULL, 'UGHHGGHYY', 'jhyuy', 'Car', 'active', '2026-08-16 13:46:05', '2026-08-16 13:46:05');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `activity_logs`
--
ALTER TABLE `activity_logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_log_actor` (`actor_type`,`actor_id`),
  ADD KEY `idx_log_module` (`module`);

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

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

--
-- Indexes for table `bus_requests`
--
ALTER TABLE `bus_requests`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `request_code` (`request_code`),
  ADD KEY `idx_br_user` (`user_id`),
  ADD KEY `idx_br_status` (`status`);

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

--
-- Indexes for table `documents`
--
ALTER TABLE `documents`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_doc_owner` (`owner_type`,`owner_id`),
  ADD KEY `idx_doc_user` (`user_id`);

--
-- Indexes for table `flight_requests`
--
ALTER TABLE `flight_requests`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `request_code` (`request_code`),
  ADD KEY `idx_fr_user` (`user_id`),
  ADD KEY `idx_fr_status` (`status`);

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

--
-- Indexes for table `gps_locations`
--
ALTER TABLE `gps_locations`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_loc_vehicle_time` (`vehicle_id`,`recorded_at`);

--
-- Indexes for table `insurance_requests`
--
ALTER TABLE `insurance_requests`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `request_code` (`request_code`),
  ADD KEY `idx_ins_user` (`user_id`),
  ADD KEY `idx_ins_status` (`status`);

--
-- Indexes for table `notifications`
--
ALTER TABLE `notifications`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_notif_user` (`user_id`);

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

--
-- Indexes for table `otp_requests`
--
ALTER TABLE `otp_requests`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_otp_mobile` (`mobile`);

--
-- Indexes for table `payments`
--
ALTER TABLE `payments`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `transaction_id` (`transaction_id`),
  ADD KEY `fk_pay_user` (`user_id`),
  ADD KEY `idx_pay_owner` (`owner_type`,`owner_id`),
  ADD KEY `idx_pay_status` (`status`);

--
-- Indexes for table `services`
--
ALTER TABLE `services`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `slug` (`slug`),
  ADD KEY `idx_services_category` (`category_id`),
  ADD KEY `idx_services_status` (`status`);

--
-- Indexes for table `service_forms`
--
ALTER TABLE `service_forms`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_sf_request` (`service_request_id`);

--
-- Indexes for table `service_requests`
--
ALTER TABLE `service_requests`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `request_code` (`request_code`),
  ADD KEY `fk_sr_admin` (`assigned_admin_id`),
  ADD KEY `idx_sr_user` (`user_id`),
  ADD KEY `idx_sr_status` (`status`),
  ADD KEY `idx_sr_service` (`service_id`);

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

--
-- Indexes for table `support_tickets`
--
ALTER TABLE `support_tickets`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `ticket_code` (`ticket_code`),
  ADD KEY `idx_ticket_user` (`user_id`),
  ADD KEY `idx_ticket_status` (`status`);

--
-- Indexes for table `taxi_requests`
--
ALTER TABLE `taxi_requests`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `request_code` (`request_code`),
  ADD KEY `idx_taxi_user` (`user_id`),
  ADD KEY `idx_taxi_status` (`status`);

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

--
-- Indexes for table `tour_requests`
--
ALTER TABLE `tour_requests`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `request_code` (`request_code`),
  ADD KEY `fk_tourreq_pkg` (`tour_package_id`),
  ADD KEY `idx_tourreq_user` (`user_id`);

--
-- Indexes for table `train_requests`
--
ALTER TABLE `train_requests`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `request_code` (`request_code`),
  ADD KEY `idx_tr_user` (`user_id`),
  ADD KEY `idx_tr_status` (`status`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `mobile` (`mobile`),
  ADD KEY `idx_users_mobile` (`mobile`),
  ADD KEY `idx_users_status` (`status`);

--
-- Indexes for table `vehicles`
--
ALTER TABLE `vehicles`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_veh_device` (`gps_device_id`),
  ADD KEY `idx_veh_user` (`user_id`);

--
-- AUTO_INCREMENT for dumped tables
--

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

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

--
-- AUTO_INCREMENT for table `banners`
--
ALTER TABLE `banners`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `bus_requests`
--
ALTER TABLE `bus_requests`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

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

--
-- AUTO_INCREMENT for table `documents`
--
ALTER TABLE `documents`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `flight_requests`
--
ALTER TABLE `flight_requests`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `gps_devices`
--
ALTER TABLE `gps_devices`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

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

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

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

--
-- AUTO_INCREMENT for table `offers`
--
ALTER TABLE `offers`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

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

--
-- AUTO_INCREMENT for table `payments`
--
ALTER TABLE `payments`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `services`
--
ALTER TABLE `services`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `service_forms`
--
ALTER TABLE `service_forms`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `service_requests`
--
ALTER TABLE `service_requests`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

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

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

--
-- AUTO_INCREMENT for table `taxi_requests`
--
ALTER TABLE `taxi_requests`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `tour_packages`
--
ALTER TABLE `tour_packages`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `tour_requests`
--
ALTER TABLE `tour_requests`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `train_requests`
--
ALTER TABLE `train_requests`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;

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

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `bus_requests`
--
ALTER TABLE `bus_requests`
  ADD CONSTRAINT `fk_br_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `documents`
--
ALTER TABLE `documents`
  ADD CONSTRAINT `fk_doc_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `flight_requests`
--
ALTER TABLE `flight_requests`
  ADD CONSTRAINT `fk_fr_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `gps_locations`
--
ALTER TABLE `gps_locations`
  ADD CONSTRAINT `fk_loc_vehicle` FOREIGN KEY (`vehicle_id`) REFERENCES `vehicles` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `insurance_requests`
--
ALTER TABLE `insurance_requests`
  ADD CONSTRAINT `fk_ins_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `notifications`
--
ALTER TABLE `notifications`
  ADD CONSTRAINT `fk_notif_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `payments`
--
ALTER TABLE `payments`
  ADD CONSTRAINT `fk_pay_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `services`
--
ALTER TABLE `services`
  ADD CONSTRAINT `fk_services_category` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`);

--
-- Constraints for table `service_forms`
--
ALTER TABLE `service_forms`
  ADD CONSTRAINT `fk_sf_request` FOREIGN KEY (`service_request_id`) REFERENCES `service_requests` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `service_requests`
--
ALTER TABLE `service_requests`
  ADD CONSTRAINT `fk_sr_admin` FOREIGN KEY (`assigned_admin_id`) REFERENCES `admins` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_sr_service` FOREIGN KEY (`service_id`) REFERENCES `services` (`id`),
  ADD CONSTRAINT `fk_sr_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `support_tickets`
--
ALTER TABLE `support_tickets`
  ADD CONSTRAINT `fk_ticket_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `taxi_requests`
--
ALTER TABLE `taxi_requests`
  ADD CONSTRAINT `fk_taxi_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `tour_requests`
--
ALTER TABLE `tour_requests`
  ADD CONSTRAINT `fk_tourreq_pkg` FOREIGN KEY (`tour_package_id`) REFERENCES `tour_packages` (`id`),
  ADD CONSTRAINT `fk_tourreq_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `train_requests`
--
ALTER TABLE `train_requests`
  ADD CONSTRAINT `fk_tr_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `vehicles`
--
ALTER TABLE `vehicles`
  ADD CONSTRAINT `fk_veh_device` FOREIGN KEY (`gps_device_id`) REFERENCES `gps_devices` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `fk_veh_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
