-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: 09 نوفمبر 2025 الساعة 22:31
-- إصدار الخادم: 10.4.32-MariaDB
-- PHP Version: 8.2.12

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: `rest_db`
--

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

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

CREATE TABLE `admins` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `email` varchar(100) NOT NULL,
  `password` varchar(255) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `admins` (`id`, `name`, `email`, `password`, `created_at`) VALUES
(1, 'مدير النظام', 'admin@max.com', '$2y$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi', '2025-11-02 21:02:02');

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

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

CREATE TABLE `captains` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `phone` varchar(20) NOT NULL,
  `password` varchar(255) NOT NULL,
  `vehicle_info` varchar(255) DEFAULT NULL,
  `status` enum('active','inactive') DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `captains` (`id`, `name`, `phone`, `password`, `vehicle_info`, `status`, `created_at`) VALUES
(1, 'aws', '774052277', '$2y$10$CpBYkTM1IRuWBegJoH1Dj.2dqJMYucBPj4iKqNCrTYiPlDQAkLveG', '', 'active', '2025-11-02 21:07:17');

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

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

CREATE TABLE `categories` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `categories` (`id`, `name`, `created_at`) VALUES
(1, 'مقبلات', '2025-11-02 21:02:02'),
(2, 'أطباق رئيسية', '2025-11-02 21:02:02'),
(4, 'حلويات', '2025-11-02 21:02:02'),
(5, 'مأكولات', '2025-11-05 16:06:30');

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

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

CREATE TABLE `customers` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `phone` varchar(20) NOT NULL,
  `password` varchar(255) NOT NULL,
  `address` text NOT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `customers` (`id`, `name`, `phone`, `password`, `address`, `created_at`) VALUES
(1, 'awsan', '773489852', '$2y$10$3eBNfhgNLTnFmgOX3FYqOeti6o6dcjVyKEwk3gnZW7fbTxHX4PsKO', 'ذمار حارة الصلاحي', '2025-11-02 21:40:07');

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

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

CREATE TABLE `meals` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL,
  `description` text DEFAULT NULL,
  `price` decimal(10,2) NOT NULL,
  `category_id` int(11) DEFAULT NULL,
  `image` varchar(255) DEFAULT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `meals` (`id`, `name`, `description`, `price`, `category_id`, `image`, `is_active`, `created_at`) VALUES
(1, 'دجاج ', 'مشوي ضخم', 1000.00, 2, '6907d369a4732.jpg', 1, '2025-11-02 21:55:37'),
(2, 'عصيد', 'عصيد شام', 750.00, 2, '6907dcd9de15d.png', 1, '2025-11-02 22:36:09'),
(3, 'شوارما', 'فرانسي', 150.00, 1, '690e44e2afcb4.jpg', 1, '2025-11-02 22:40:07');

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

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

CREATE TABLE `orders` (
  `id` int(11) NOT NULL,
  `customer_id` int(11) NOT NULL,
  `total` decimal(10,2) NOT NULL,
  `status` enum('pending','accepted','on_the_way','delivered') DEFAULT 'pending',
  `captain_id` int(11) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `notes` text DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `orders` (`id`, `customer_id`, `total`, `status`, `captain_id`, `created_at`, `notes`) VALUES
(1, 1, 4800.00, 'delivered', 1, '2025-11-02 22:44:46', ''),
(2, 1, 2250.00, 'delivered', 1, '2025-11-02 22:58:30', ''),
(3, 1, 1800.00, 'delivered', 1, '2025-11-02 23:33:24', ''),
(4, 1, 1300.00, 'delivered', 1, '2025-11-03 08:29:42', ''),
(5, 1, 2650.00, 'delivered', 1, '2025-11-03 13:54:30', ''),
(9, 1, 2300.00, 'delivered', 1, '2025-11-07 17:58:00', ''),
(10, 1, 150.00, 'delivered', 1, '2025-11-09 15:33:11', ''),
(11, 1, 750.00, 'delivered', 1, '2025-11-09 15:34:13', ''),
(12, 1, 1150.00, 'delivered', 1, '2025-11-09 16:05:57', ''),
(13, 1, 750.00, 'delivered', 1, '2025-11-09 16:06:24', ''),
(14, 1, 750.00, 'delivered', 1, '2025-11-09 16:07:10', ''),
(15, 1, 150.00, 'delivered', 1, '2025-11-09 20:24:12', ''),
(16, 1, 1900.00, 'accepted', 1, '2025-11-09 20:26:33', ''),
(17, 1, 750.00, 'pending', NULL, '2025-11-09 20:48:08', ''),
(18, 1, 750.00, 'pending', NULL, '2025-11-09 20:52:43', ''),
(19, 1, 1000.00, 'pending', NULL, '2025-11-09 20:59:00', ''),
(20, 1, 150.00, 'pending', NULL, '2025-11-09 20:59:31', ''),
(21, 1, 150.00, 'pending', NULL, '2025-11-09 20:59:44', ''),
(22, 1, 150.00, 'accepted', 1, '2025-11-09 21:01:28', ''),
(23, 1, 1000.00, 'pending', NULL, '2025-11-09 21:03:33', ''),
(24, 1, 150.00, 'accepted', 1, '2025-11-09 21:04:27', ''),
(25, 1, 1000.00, 'pending', NULL, '2025-11-09 21:06:21', ''),
(26, 1, 300.00, 'pending', NULL, '2025-11-09 21:07:23', '');

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

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

CREATE TABLE `order_items` (
  `id` int(11) NOT NULL,
  `order_id` int(11) NOT NULL,
  `meal_id` int(11) NOT NULL,
  `quantity` int(11) NOT NULL,
  `price` decimal(10,2) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `order_items` (`id`, `order_id`, `meal_id`, `quantity`, `price`) VALUES
(1, 1, 1, 3, 1000.00),
(2, 1, 2, 2, 750.00),
(3, 1, 3, 2, 150.00),
(4, 2, 2, 3, 750.00),
(5, 3, 2, 2, 750.00),
(6, 3, 3, 2, 150.00),
(7, 4, 1, 1, 1000.00),
(8, 4, 3, 2, 150.00),
(9, 5, 1, 1, 1000.00),
(10, 5, 2, 2, 750.00),
(11, 5, 3, 1, 150.00),
(18, 9, 3, 2, 150.00),
(20, 10, 3, 1, 150.00),
(21, 11, 2, 1, 750.00),
(22, 12, 1, 1, 1000.00),
(23, 12, 3, 1, 150.00),
(24, 13, 2, 1, 750.00),
(25, 14, 2, 1, 750.00),
(26, 15, 3, 1, 150.00),
(27, 16, 1, 1, 1000.00),
(28, 16, 2, 1, 750.00),
(29, 16, 3, 1, 150.00),
(30, 17, 2, 1, 750.00),
(31, 18, 2, 1, 750.00),
(32, 19, 1, 1, 1000.00),
(33, 20, 3, 1, 150.00),
(34, 21, 3, 1, 150.00),
(35, 22, 3, 1, 150.00),
(36, 23, 1, 1, 1000.00),
(37, 24, 3, 1, 150.00),
(38, 25, 1, 1, 1000.00),
(39, 26, 3, 2, 150.00);

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

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

CREATE TABLE `settings` (
  `id` int(11) NOT NULL,
  `name` varchar(100) NOT NULL DEFAULT 'Max',
  `address` text DEFAULT NULL,
  `phone` varchar(20) DEFAULT NULL,
  `whatsapp` varchar(20) DEFAULT NULL,
  `delivery_fee` decimal(10,2) DEFAULT 0.00
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `settings` (`id`, `name`, `address`, `phone`, `whatsapp`, `delivery_fee`) VALUES
(1, 'ماكس', 'ذمار شارع رداع ', '774052277', '774052277', 0.00);

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

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

CREATE TABLE `sliders` (
  `id` int(11) NOT NULL,
  `image` varchar(255) NOT NULL,
  `is_active` tinyint(1) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

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

INSERT INTO `sliders` (`id`, `image`, `is_active`, `created_at`) VALUES
(2, '6907d4eadef1e.jpg', 1, '2025-11-02 22:02:18'),
(3, '6907d5027ca9d.png', 1, '2025-11-02 22:02:42'),
(4, '6907d537bdc52.png', 1, '2025-11-02 22:03:35'),
(5, '6908688beedf8.png', 1, '2025-11-03 08:32:11');

--
-- Indexes for dumped tables
--

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

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

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

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

--
-- Indexes for table `meals`
--
ALTER TABLE `meals`
  ADD PRIMARY KEY (`id`),
  ADD KEY `category_id` (`category_id`);

--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
  ADD PRIMARY KEY (`id`),
  ADD KEY `customer_id` (`customer_id`),
  ADD KEY `captain_id` (`captain_id`);

--
-- Indexes for table `order_items`
--
ALTER TABLE `order_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `order_id` (`order_id`),
  ADD KEY `meal_id` (`meal_id`);

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

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

--
-- AUTO_INCREMENT for dumped tables
--

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

--
-- AUTO_INCREMENT for table `captains`
--
ALTER TABLE `captains`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `categories`
--
ALTER TABLE `categories`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `customers`
--
ALTER TABLE `customers`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

--
-- AUTO_INCREMENT for table `meals`
--
ALTER TABLE `meals`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=27;

--
-- AUTO_INCREMENT for table `order_items`
--
ALTER TABLE `order_items`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=40;

--
-- AUTO_INCREMENT for table `settings`
--
ALTER TABLE `settings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `sliders`
--
ALTER TABLE `sliders`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;

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

--
-- قيود الجداول `meals`
--
ALTER TABLE `meals`
  ADD CONSTRAINT `meals_ibfk_1` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `orders`
--
ALTER TABLE `orders`
  ADD CONSTRAINT `orders_ibfk_1` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `orders_ibfk_2` FOREIGN KEY (`captain_id`) REFERENCES `captains` (`id`) ON DELETE SET NULL;

--
-- قيود الجداول `order_items`
--
ALTER TABLE `order_items`
  ADD CONSTRAINT `order_items_ibfk_1` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `order_items_ibfk_2` FOREIGN KEY (`meal_id`) REFERENCES `meals` (`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 */;
