# Function setRoomingPlanCharter

### <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>

این متد به عنوان نقطه پایانی برای تخصیص یک مسافر به یک اتاق خاص در یک پلن اتاق‌بندی عمل می‌کند. هدف اصلی آن، ثبت یا به‌روزرسانی رکورد مربوط به “رومینگ” (تخصیص اتاق) در جدول `charter_plans_rooming` است. متد ابتدا بررسی می‌کند که آیا مسافر از قبل به اتاق دیگری در همین پلن تخصیص داده شده است یا خیر. اگر چنین باشد، آن تخصیص قبلی را حذف می‌کند تا از تخصیص دوگانه یک مسافر جلوگیری شود. سپس، رکورد جدیدی برای تخصیص مسافر (`reserve_id`) به اتاق (`room_id`) در پلن (`plan_id`) درج می‌کند. این فرآیند اطمینان می‌دهد که هر مسافر در هر لحظه فقط به یک اتاق در یک پلن مشخص متصل است.

<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);">حذف تخصیص قبلی مسافر در همان پلن قبل از ایجاد تخصیص جدید.</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);">درج یک رکورد در جدول `charter_plans_rooming`.</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);">بازگرداندن پاسخ `201 Created` در صورت موفقیت.</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: 225.688px; background-color: rgb(236, 202, 250); border: 1px inset rgb(206, 212, 217);"><colgroup><col style="width: 49.9509%;"></col><col style="width: 12.5246%;"></col><col style="width: 12.5246%;"></col><col style="width: 25.0491%;"></col></colgroup><thead><tr style="height: 31.4583px;"><td style="height: 31.4583px; 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: 31.4583px; 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: 31.4583px;"><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: 49.5417px;"><td style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 49.5417px;"><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;">`Route`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 49.5417px;">**<span style="color: black; mso-color-alt: windowtext;">`integer`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 49.5417px;"><span style="color: rgb(0, 0, 0);">**`$request->id`**</span></td></tr><tr style="height: 48.2292px;"><td style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 48.2292px;"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">شناسه پلن اتاق‌بندی.</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: 48.2292px;">**<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: 48.2292px;"><span lang="AR-SA" style="color: rgb(0, 0, 0);">**<span style="color: black; mso-color-alt: windowtext;">`$request->plan_id`</span>**</span></td></tr><tr style="height: 49.5417px;"><td style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 49.5417px;"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">شناسه اتاق در پلن.</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: 49.5417px;">**<span style="color: black; mso-color-alt: windowtext;">`integer`</span>**</td><td dir="ltr" style="border-color: rgb(206, 212, 217); background-color: rgb(236, 202, 250); height: 49.5417px;"><span lang="AR-SA" style="color: rgb(0, 0, 0);">**<span style="color: black; mso-color-alt: windowtext;">`$request->room_id`</span>**</span></td></tr><tr style="height: 46.9167px;"><td style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 46.9167px;"><span style="color: rgb(0, 0, 0);">**<span lang="AR-SA">شناسه رزرو مسافری که باید به اتاق تخصیص داده شود.</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: 46.9167px;">**<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: 46.9167px;"><span lang="AR-SA" style="color: rgb(0, 0, 0);">**<span style="color: black; mso-color-alt: windowtext;">`$request->reserve_id`</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: 109.604px; 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: 31.4583px;"><td style="height: 31.4583px; 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: 31.4583px; 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.4583px; background-color: rgb(206, 212, 217);"><td style="height: 48.4583px; 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;">در صورت موفقیت، یک پاسخ خالی با کد `201 Created`.</span></span>**</span></td><td style="height: 48.4583px; 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 style="height: 29.6875px;"><td style="border-color: rgb(206, 212, 217); background-color: rgb(255, 255, 255); height: 29.6875px;"><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); height: 29.6875px;"><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 style="color: rgb(0, 0, 0); text-decoration: underline;">سناریو</span></span>: انتقال مسافر با رزرو شناسه ۵۴۳۲ به اتاق با شناسه ۱۰۱ در پلن ۵**

- **Request Body:**

<div class="code-header" dir="ltr" id="bkmrk-json"><span class="language-label">json</span></div>```
    {
        "plan_id": 5,
        "room_id": 101,
        "reserve_id": 5432
    }

```

- **Action:**

1. `DELETE FROM charter_plans_rooming WHERE plan_id = 5 AND reserve_id = 5432` اجرا می‌شود تا هرگونه تخصیص قبلی پاک شود.
2. `INSERT INTO charter_plans_rooming (plan_id, room_id, reserve_id) VALUES (5, 101, 5432)` اجرا می‌شود.

- **Response:**
- `HTTP Status`: `201 Created`