#P1687
GET /v2/charter/flight-rate
Charter: Get Approved Flight Rate
این اندپوینت نرخ مصوب (Approved Flight Rate) میان دو فرودگاه را بر اساس جدول approved_flight_rate بازیابی میکند. سیستم ابتدا دقیقاً مسیر origin → destination را جستجو میکند و در صورت نبود، مسیر destination → origin را نیز بررسی میکند. در صورت نیافتن رکورد، خروجی با مقدارهای پیشفرض (0) برگردانده میشود.
Request Overview
URL:
/v2/charter/flight-rateMethod: GET
Controller: CharterController@getApprovedFlightRate
Middleware: authWithJwt
Access Control
- دسترسی فقط با JWT معتبر
- هیچ شرط branch، نقش یا core middleware وجود ندارد
- ورودیها مستقیماً از Query Params خوانده میشوند
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| origin | integer | yes | ID فرودگاه مبدا |
| destination | integer | yes | ID فرودگاه مقصد |
Database Table Reference
اطلاعات نرخهای مصوب از جدول زیر خوانده میشود:
| Column | Type | Description |
|---|---|---|
| id | integer | Primary Key |
| origin | integer | ID فرودگاه مبدا |
| destination | integer | ID فرودگاه مقصد |
| least | integer | کمترین نرخ مصوب |
| most | integer | بیشترین نرخ مصوب |
| updated_at | datetime | زمان آخرین بروزرسانی نرخ |
Core Processing Logic
$result = DB::table('approved_flight_rate')
->where(function ($q) use ($request) {
$q->where('origin', $request->get('origin'))
->where('destination', $request->get('destination'));
})
->orWhere(function ($q) use ($request) {
$q->where('origin', $request->get('destination'))
->where('destination', $request->get('origin'));
})
->first();
- ابتدا رکورد exact-match برای origin → destination جستجو میشود
- در صورت عدم وجود، مسیر معکوس destination → origin بررسی میشود
- اگر رکورد یافت شود: مقادیر واقعی least/most برگشت داده میشود
- اگر یافت نشود: least = 0 و most = 0 و updated_at = now()
Response (Success — Found)
در صورتی که رکورد واقعی در جدول موجود باشد:
{
"status": true,
"time": 1710000000,
"data": {
"origin": 1,
"destination": 2,
"least": 850000,
"most": 1350000,
"updated_at": "2024-09-12 16:40:55"
}
}
Response (Success — Not Found)
اگر ریتی برای این مسیر ثبت نشده باشد:
{
"status": true,
"time": 1710000000,
"data": {
"origin": 1,
"destination": 2,
"least": 0,
"most": 0,
"updated_at": "2025-02-12 14:10:21"
}
}
Response (Error)
در صورت بروز Exception:
{
"status": false,
"time": 1710000000,
"message": "SQLSTATE[HY000]: ...",
"trace": [ ... ]
}
Flowchart
Validate JWT
↓
Read Query Params: origin, destination
↓
DB Query: origin → destination
↓
If not found → DB Query: destination → origin
↓
Record Found?
↓
Yes → Return real least/most
No → Return least=0, most=0, now()
↓
Return JSON (status=true)