PHPackages                             vinhdev/travel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. vinhdev/travel

ActiveLibrary

vinhdev/travel
==============

it for travel project

040PHP

Since Dec 2Pushed 5mo agoCompare

[ Source](https://github.com/Vinh-Dev-16/travel_base)[ Packagist](https://packagist.org/packages/vinhdev/travel)[ RSS](/packages/vinhdev-travel/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Travel Package
==============

[](#travel-package)

Một package Laravel cung cấp các tính năng cơ bản cho ứng dụng du lịch, bao gồm Firebase integration, MongoDB support, Redis caching và các helper functions hữu ích.

📋 Yêu cầu hệ thống
------------------

[](#-yêu-cầu-hệ-thống)

- PHP &gt;= 8.1
- Laravel &gt;= 10.0 (tùy chọn - package cũng hoạt động standalone)
- MongoDB extension (nếu sử dụng MongoDB)
- Redis (nếu sử dụng Redis)

🚀 Cài đặt
---------

[](#-cài-đặt)

### 1. Cài đặt Package

[](#1-cài-đặt-package)

```
composer require vinhdev/travel
```

### 2. Publish Config (Laravel)

[](#2-publish-config-laravel)

```
php artisan vendor:publish --tag=travel-config
```

### 3. Cấu hình Environment

[](#3-cấu-hình-environment)

Thêm vào file `.env`:

```
# Firebase Configuration
FIREBASE_DATABASE_URI=https://your-project-id-default-rtdb.firebaseio.com/

# MongoDB Configuration
MONGODB_CONNECTION=mongodb://localhost:27017
MONGODB_DATABASE=travel_db

# Redis Configuration
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=null
REDIS_DATABASE=0
```

### 4. Cài đặt Firebase Service Account

[](#4-cài-đặt-firebase-service-account)

1. Tải file service account JSON từ Firebase Console
2. Đặt file vào `storage/app/firebase-service-account.json`
3. Hoặc cập nhật đường dẫn trong `config/travel.php`

📚 Sử dụng
---------

[](#-sử-dụng)

### BaseController

[](#basecontroller)

```
use Vinhdev\Travel\Contracts\Controllers\BaseController;

$controller = new BaseController();

// Response JSON với message
$response = $controller->responseJson(200, 'Thành công');

// Response JSON với data
$response = $controller->responseJsonData(200, [
    'users' => $users,
    'total' => 100
]);
```

### BaseModel (MongoDB)

[](#basemodel-mongodb)

```
use Vinhdev\Travel\Contracts\Models\BaseModel;

class User extends BaseModel
{
    protected $collection = 'users';

    // Model sẽ tự động:
    // - Tạo _id mới khi tạo record
    // - Set created_at, updated_at timestamps
    // - Set is_deleted = 0 (ACTIVE)
}
```

### BaseRequest

[](#baserequest)

```
use Vinhdev\Travel\Contracts\Requests\BaseRequest;

class CreateUserRequest extends BaseRequest
{
    public function rules()
    {
        return [
            'name' => 'required|string|max:255',
            'email' => 'required|email|unique:users'
        ];
    }

    // Sử dụng getDTO() để lấy thông tin user hiện tại
    public function getDTO(): GetUserInformationDTOInterface
    {
        return parent::getDTO();
    }
}
```

### FirebaseLib

[](#firebaselib)

```
use Vinhdev\Travel\Contracts\Lib\FirebaseLib;
use Vinhdev\Travel\Contracts\DataMappers\NotificationData;

// Khởi tạo (tự động lấy config từ Laravel)
$firebase = new FirebaseLib();

// Hoặc truyền config trực tiếp
$firebase = new FirebaseLib([
    'credential_path' => '/path/to/firebase.json',
    'database_uri' => 'https://your-project.firebaseio.com/'
]);

// Upload file
$result = $firebase->uploadFile('/path/to/file.jpg', 'image.jpg');

// Lấy URL file
$url = $firebase->getFileUrl('Travel/image.jpg');

// Gửi notification
$notification = new NotificationData('Tiêu đề', 'Nội dung thông báo');
$firebase->sendNotification($token, $notification);

// Lưu dữ liệu vào Firebase Database
$firebase->createData('users', [
    'name' => 'John Doe',
    'email' => 'john@example.com'
]);

// Lấy dữ liệu
$comments = $firebase->getComments();

// Xóa dữ liệu
$firebase->deleteData('users');
```

### RedisLib

[](#redislib)

```
use Vinhdev\Travel\Contracts\Lib\RedisLib;

$redis = new RedisLib();

// Set cache
$redis->set('user:1', json_encode($userData), 3600);

// Get cache
$userData = $redis->get('user:1');

// Delete cache
$redis->delete('user:1');
```

🔧 Cấu hình
----------

[](#-cấu-hình)

### Config File (config/travel.php)

[](#config-file-configtravelphp)

```
return [
    'firebase' => [
        'credential_path' => storage_path('app/firebase-service-account.json'),
        'database_uri' => env('FIREBASE_DATABASE_URI'),
    ],

    'mongodb' => [
        'connection' => env('MONGODB_CONNECTION', 'mongodb://localhost:27017'),
        'database' => env('MONGODB_DATABASE', 'travel_db'),
    ],

    'redis' => [
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'port' => env('REDIS_PORT', 6379),
        'password' => env('REDIS_PASSWORD'),
        'database' => env('REDIS_DATABASE', 0),
    ],
];
```

📦 Các Class có sẵn
------------------

[](#-các-class-có-sẵn)

### Controllers

[](#controllers)

- `BaseController` - Controller cơ bản với response helpers

### Models

[](#models)

- `BaseModel` - Model cơ bản cho MongoDB với soft delete

### Requests

[](#requests)

- `BaseRequest` - Request cơ bản với validation và DTO helpers

### Libraries

[](#libraries)

- `FirebaseLib` - Firebase integration (Auth, Database, Storage, Messaging)
- `RedisLib` - Redis caching helpers

### DTOs

[](#dtos)

- `NotificationData` - Data class cho Firebase notifications
- `UserInformationDTO` - Data class cho thông tin user

### Enums

[](#enums)

- `SoftDelete` - Enum cho trạng thái soft delete

### Traits

[](#traits)

- `GetUserInformationDTOTrait` - Trait cho user information
- `HasPermissionTrait` - Trait cho permission checking
- `IndexPaginateDTOTrait` - Trait cho pagination

🛠️ Development
--------------

[](#️-development)

### Cài đặt dependencies

[](#cài-đặt-dependencies)

```
composer install
```

### Chạy tests

[](#chạy-tests)

```
composer test
```

📝 Changelog
-----------

[](#-changelog)

### v1.0.0

[](#v100)

- BaseController với JSON response helpers
- BaseModel với MongoDB support và soft delete
- BaseRequest với validation và DTO integration
- FirebaseLib với đầy đủ tính năng Firebase
- RedisLib với caching helpers
- Service Provider cho Laravel integration
- Config system linh hoạt

🤝 Contributing
--------------

[](#-contributing)

1. Fork repository
2. Tạo feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Tạo Pull Request

📄 License
---------

[](#-license)

Package này được phát hành dưới [MIT License](LICENSE).

👨‍💻 Author
----------

[](#‍-author)

**Vinh Dev 16**

- Email:
- GitHub: [@vinhdev16](https://github.com/vinhdev16)

🙏 Acknowledgments
-----------------

[](#-acknowledgments)

- Laravel Framework
- Firebase PHP SDK
- MongoDB Laravel Package
- Redis PHP Extension

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance48

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity13

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/bd06039bd438480efa4dad32f0ee265e320d13db299bef55ea8c3889a6dea5d1?d=identicon)[Vinh-Dev-16](/maintainers/Vinh-Dev-16)

---

Top Contributors

[![Vinh-Dev-16](https://avatars.githubusercontent.com/u/112423916?v=4)](https://github.com/Vinh-Dev-16 "Vinh-Dev-16 (27 commits)")

### Embed Badge

![Health badge](/badges/vinhdev-travel/health.svg)

```
[![Health](https://phpackages.com/badges/vinhdev-travel/health.svg)](https://phpackages.com/packages/vinhdev-travel)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
