🏨 Hotel Management System

PHP Raw Project - Database Connection & API System

📊 Project Overview

🧪 Test Database Connection 📡 API Documentation

🗄️ Database Models

🏨 Hotel Model

  • Table: hotels
  • Relationships:
  • → hasMany: rooms
  • → belongsTo: country, province
  • Key Fields: name, rating, location

🛏️ Room Model

  • Table: rooms
  • Relationships:
  • → belongsTo: hotel
  • → hasMany: rateplanes
  • Key Fields: name, capacity, amenities

📋 Rateplane Model

  • Table: rateplanes
  • Relationships:
  • → belongsTo: room
  • → hasMany: prices
  • Key Fields: meal_type, policies

💰 Price Model

  • Table: prices
  • Relationships:
  • → belongsTo: rateplane
  • Key Fields: price, date, availability

🔌 API Endpoints

GET /

Get all hotels với pagination

?page=1&limit=10

GET /hotels/search

Search hotels theo criteria

?name=hotel&location_id=1

GET /hotels/{id}

Get chi tiết hotel với rooms & rateplanes

/hotels/1

GET /rooms/search

Tìm phòng available

?check_in=2024-01-01&check_out=2024-01-02

GET /rooms/{id}/pricing

Get giá phòng theo khoảng thời gian

/rooms/1/pricing?check_in=2024-01-01

POST /bookings/calculate

Tính toán giá booking

{"rateplan_id": 1, "check_in": "2024-01-01"}

🛠️ Project Structure

phppde/ ├── config/ │ └── database.php # Database configuration & connection ├── models/ │ ├── BaseModel.php # Base model class (như Eloquent) │ ├── Hotel.php # Hotel model │ ├── Room.php # Room model │ ├── Rateplane.php # Rateplane model │ └── Price.php # Price model ├── services/ │ └── HotelService.php # Business logic services ├── autoload.php # Class autoloader ├── api.php # RESTful API endpoints ├── test.php # Database connection test └── index.php # This dashboard page

⚙️ Database Configuration

Ready to use PHP Raw

🚀 Quick Start

  1. Test Connection: Truy cập test.php để kiểm tra kết nối database
  2. API Usage: Sử dụng api.php làm endpoint chính
  3. Models: Sử dụng các model trong folder models/
  4. Services: Business logic trong folder services/