# Function updateCharterReservation

### <a name="func_1"></a>

#### <span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">·</span></span><span lang="AR-SA"><span style="mso-spacerun: yes;"> </span>هدف:</span>

این متد برای ویرایش اطلاعات رزرو یک یا چند مسافر به صورت همزمان استفاده می‌شود. کاربر می‌تواند اطلاعات هویتی (مانند نام، کد ملی)، اطلاعات تماس (ایمیل، موبایل) و یا حتی وضعیت رزرو (مثلاً تغییر از حالت موقت به قطعی) را برای لیستی از رزروها تغییر دهد. متد قبل از اعمال تغییرات، اعتبارسنجی‌های لازم را روی داده‌های جدید انجام می‌دهد تا از صحت آن‌ها اطمینان حاصل کند. این عملیات به صورت اتمیک برای هر رزرو انجام می‌شود تا از بروز خطا و ناقص ماندن اطلاعات جلوگیری شود.

<table border="1" class="align-center" id="bkmrk-%D9%88%DB%8C%DA%98%DA%AF%DB%8C%E2%80%8C%D9%87%D8%A7-%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA-%D9%87%D8%AF%D9%81" style="border-collapse: collapse; width: 80.9524%; height: 196.891px; background-color: rgb(236, 202, 250); border: 1px inset rgb(206, 212, 217);"><colgroup><col style="width: 50.0736%;"></col><col style="width: 50.0736%;"></col></colgroup><thead><tr style="height: 30.7969px;"><td style="height: 30.7969px; border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">ویژگی‌ها</span>**</span></td><td style="height: 30.7969px; border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">توضیحات</span>**</span></td></tr></thead><tbody><tr style="height: 29.7969px; background-color: rgb(206, 212, 217);"><td style="height: 29.7969px; border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">هدف کلی</span>**</span></td><td style="height: 29.7969px; border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span lang="AR-SA" style="color: rgb(0, 0, 0);">ویرایش اطلاعات یک یا چند رزرو موجود در یک چارتر.</span></td></tr><tr style="height: 29.7969px; background-color: rgb(206, 212, 217);"><td style="height: 29.7969px; border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">پردازش دسته‌ای</span>**</span></td><td style="height: 29.7969px; border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255);"><span lang="AR-SA" style="color: rgb(0, 0, 0);">قابلیت آپدیت کردن چندین رزرو (`reservation_id`) با یک درخواست واحد.</span></td></tr><tr style="height: 29.7969px; background-color: rgb(206, 212, 217);"><td style="height: 29.7969px; border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">اعتبارسنجی ورودی</span>**</span></td><td style="height: 29.7969px; border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">ولیدیشن داده‌های جدید قبل از ذخیره‌سازی (مانند فرمت صحیح ایمیل و موبایل).</span></td></tr><tr style="height: 30.1094px; background-color: rgb(206, 212, 217);"><td style="height: 30.1094px; border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">به‌روزرسانی انتخابی</span>**</span></td><td style="height: 30.1094px; border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255);"><span style="color: rgb(0, 0, 0);">فقط فیلدهایی که در درخواست ارسال شوند، به‌روزرسانی می‌شوند.</span></td></tr><tr><td style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">عملیات اتمی</span>**</span></td><td style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">هر رزرو به صورت مستقل و کامل آپدیت می‌شود.</span></td></tr></tbody></table>

<div align="right" id="bkmrk-"></div>---

#### <span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span><span lang="AR-SA">ورودی</span><span lang="FA" style="font-family: 'Calibri',sans-serif; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-language: FA;">‌ها (پارامتر‌ها):</span>

<span dir="LTR"> </span>

<table border="1" class="align-center" id="bkmrk-%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA-%D9%86%D9%88%D8%B9-%D8%AF%D8%A7%D8%AF%D9%87-%D9%86%D8%A7%D9%85" style="border-collapse: collapse; width: 80.9524%; height: 286.906px; background-color: rgb(236, 202, 250); border: 1px inset rgb(206, 212, 217);"><colgroup><col style="width: 49.9524%;"></col><col style="width: 12.5249%;"></col><col style="width: 12.5249%;"></col><col style="width: 25.0499%;"></col></colgroup><thead><tr style="height: 30.7969px;"><td style="height: 30.7969px; border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">توضیحات</span>**</span></td><td style="border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">موقعیت</span>**</span></td><td style="height: 30.7969px; border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">نوع داده</span>**</span></td><td style="border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161); height: 30.7969px;"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">نام پارمتر</span>**</span></td></tr></thead><tbody><tr style="height: 47.2188px;"><td style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 47.2188px;"><span style="color: rgb(0, 0, 0);">**آرایه‌ای از آبجکت‌های رزرو که هر کدام شامل شناسه رزرو و فیلدهای مورد نظر برای ویرایش است.**</span></td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);">**<span style="color: black; mso-color-alt: windowtext;">`Body`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 47.2188px;">**<span style="color: black; mso-color-alt: windowtext;">`array`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 47.2188px;"><span style="color: rgb(0, 0, 0);">**`$request->reservations`**</span></td></tr><tr style="height: 30.1094px;"><td style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 30.1094px;"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">(اجباری) شناسه رزرو (`reservation_id`) که قرار است ویرایش شود.</span>**</span></td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255);">**<span style="color: black; mso-color-alt: windowtext;">`Body`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 30.1094px;">**<span style="color: black; mso-color-alt: windowtext;">`integer`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 30.1094px;"><span lang="AR-SA" style="color: rgb(0, 0, 0);">**<span style="color: black; mso-color-alt: windowtext;">`$reservation['id']`</span>**</span></td></tr><tr style="height: 29.7969px;"><td style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 29.7969px;"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">(اختیاری) آبجکتی شامل اطلاعات جدید مسافر (مانند `fullname`, `identity`, `birth`, `mobile`, `email`).</span>**</span></td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);">**<span style="color: black; mso-color-alt: windowtext;">`Body`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 29.7969px;">**<span style="color: black; mso-color-alt: windowtext;">`object`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 29.7969px;"><span lang="AR-SA" style="color: rgb(0, 0, 0);">**<span style="color: black; mso-color-alt: windowtext;">`$reservation['passenger']`</span>**</span></td></tr><tr style="height: 29.7969px;"><td style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 29.7969px;"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">(اختیاری) کد وضعیت جدید رزرو (مثلاً `1` برای قطعی، `2` برای کنسل).</span>**</span></td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255);">**<span style="color: black; mso-color-alt: windowtext;">`Body`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 29.7969px;">**<span style="color: black; mso-color-alt: windowtext;">`integer`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 29.7969px;"><span lang="AR-SA" style="color: rgb(0, 0, 0);">**<span style="color: black; mso-color-alt: windowtext;">`$reservation['status']`</span>**</span></td></tr></tbody></table>

<div align="right" id="bkmrk--2"></div>---

#### <span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">·<span style="font: 7.0pt 'Times New Roman';"> </span></span></span><span lang="AR-SA">خروجی</span><span dir="LTR"> (Return)</span><span lang="FA" style="font-family: 'Calibri',sans-serif; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin; mso-bidi-language: FA;">:</span>

<span dir="LTR"> </span>

<div align="right" id="bkmrk-%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA-%D9%86%D9%88%D8%B9-%D8%AF%D8%A7%D8%AF%D9%87-%D8%B1%D8%B4%D8%AA"></div><table border="1" class="align-center" id="bkmrk-%D8%AA%D9%88%D8%B6%DB%8C%D8%AD%D8%A7%D8%AA-%D9%86%D9%88%D8%B9-%D8%AF%D8%A7%D8%AF%D9%87-%D8%B1%D8%B4%D8%AA-1" style="border-collapse: collapse; width: 80.9524%; height: 127.734px; background-color: rgb(236, 202, 250); border: 1px inset rgb(206, 212, 217);"><colgroup><col style="width: 50.0736%;"></col><col style="width: 50.0736%;"></col></colgroup><thead><tr style="height: 30.7969px;"><td style="height: 30.7969px; border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">توضیحات</span>**</span></td><td style="height: 30.7969px; border-color: rgb(206, 212, 217); background-color: rgb(132, 63, 161);"><span style="color: rgb(255, 255, 255);">**<span lang="AR-SA" style="font-family: 'B Titr';">نوع داده</span>**</span></td></tr></thead><tbody><tr style="height: 48.4688px; background-color: rgb(206, 212, 217);"><td style="height: 48.4688px; border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA"><span dir="RTL" lang="AR-SA" style="font-size: 11.0pt; line-height: 107%; font-family: 'B Nazanin'; mso-ascii-font-family: 'B Nazanin'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-font-family: 'B Nazanin'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">در صورت موفقیت کامل، یک پاسخ خالی با کد وضعیت `204 No Content` برمی‌گرداند.</span></span>**</span></td><td style="height: 48.4688px; border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span lang="AR-SA" style="color: rgb(0, 0, 0);">**<span style="font-size: 11.0pt; line-height: 107%; font-family: 'B Nazanin'; mso-ascii-font-family: 'B Nazanin'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-font-family: 'B Nazanin'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">`Illuminate\Http\JsonResponse`</span>**</span></td></tr><tr><td style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA"><span dir="RTL" lang="AR-SA" style="font-size: 11.0pt; line-height: 107%; font-family: 'B Nazanin'; mso-ascii-font-family: 'B Nazanin'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-font-family: 'B Nazanin'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">در صورت بروز خطا در حین پردازش (مثلاً پیدا نشدن یکی از رزروها)، یک پاسخ با کد `400 Bad Request` حاوی جزئیات خطا برمی‌گرداند.</span></span>**</span></td><td style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255);"><span lang="AR-SA" style="color: rgb(0, 0, 0);">**<span style="font-size: 11.0pt; line-height: 107%; font-family: 'B Nazanin'; mso-ascii-font-family: 'B Nazanin'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-font-family: 'B Nazanin'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">`Illuminate\Http\JsonResponse`</span>**</span></td></tr><tr><td style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA"><span dir="RTL" lang="AR-SA" style="font-size: 11.0pt; line-height: 107%; font-family: 'B Nazanin'; mso-ascii-font-family: 'B Nazanin'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-font-family: 'B Nazanin'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">در صورت وجود خطای اعتبارسنجی در داده‌های ورودی، یک پاسخ با کد `422 Unprocessable Entity` برمی‌گرداند.</span></span>**</span></td><td style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250);"><span lang="AR-SA" style="color: rgb(0, 0, 0);">**<span style="font-size: 11.0pt; line-height: 107%; font-family: 'B Nazanin'; mso-ascii-font-family: 'B Nazanin'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-font-family: 'B Nazanin'; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA;">`Illuminate\Http\JsonResponse`</span>**</span></td></tr></tbody></table>

---

#### <span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"><span style="mso-list: Ignore;">·</span></span><span lang="AR-SA"><span style="mso-spacerun: yes;"> </span>مثا</span>ل استفاده / سناریو:

**<span style="text-decoration: underline; background-color: rgb(251, 238, 184);">سناریو</span>: اصلاح نام خانوادگی مسافر در رزرو شماره ۱۲۳۴۵ و تغییر وضعیت رزرو شماره ۱۲۳۴۶ به کنسل شده.**

- **Request Body:**

<div class="code-header" dir="ltr" id="bkmrk-json"><span class="language-label">json</span></div>```
    {
        "reservations": [
            {
                "id": 12345,
                "passenger": {
                    "fullname": {
                        "last_name": { "fa": "اکبری", "en": "Akbari" }
                    }
                }
            },
            {
                "id": 12346,
                "status": 2
            }
        ]
    }
```

- **Action:**

1. متد درخواست را دریافت کرده و حلقه را روی آرایه `reservations` شروع می‌کند.
2. برای رزرو `12345`، آبجکت `passenger` را در دیتابیس پیدا کرده، نام خانوادگی را آپدیت و مجدداً به صورت JSON ذخیره می‌کند.
3. برای رزرو `12346`، فیلد `status` را در دیتابیس به `2` تغییر می‌دهد.

- **Response:**
- **کد وضعیت:** `204 No Content`
- **Body:** (خالی)