# Function storePledgerCharter

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

این متد یک عملکرد ساده و مشخص دارد: افزودن یک همکار (Colleague) به لیست متعهدان (Pledgers) یک شعبه. این کار با درج یک رکورد جدید در جدول `charter_pledgers` انجام می‌شود. اطلاعات لازم برای این کار، یعنی شناسه همکار (`colleague_id`) و شناسه شعبه (`branch`)، از ورودی درخواست و اطلاعات توکن کاربر استخراج می‌شود. این متد به عنوان یک نقطه پایانی سریع برای مدیریت لیست متعهدان عمل می‌کند.

<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);">درج یک رکورد جدید در جدول `charter_pledgers`.</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);">عدم وجود منطق پیچیده؛ تنها یک عملیات `insert` ساده.</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.9697%; height: 286.906px; background-color: rgb(236, 202, 250); border: 1px inset rgb(206, 212, 217);"><colgroup><col style="width: 49.9367%;"></col><col style="width: 12.4467%;"></col><col style="width: 12.4467%;"></col><col style="width: 25.0433%;"></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;">`integer`</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->colleague_id`**</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">شناسه شعبه کاربر که به صورت خودکار به درخواست اضافه می‌شود.</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;">`Token/Middleware`</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;">`$request->get('branch')`</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;">در صورت موفقیت، یک پاسخ خالی با کد `201 Created`.</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></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>ل استفاده / سناریو:

**سناریو: افزودن همکار با شناسه ۷۵ به لیست متعهدان شعبه ۲**

- **Request Body:**

<div class="code-header" dir="ltr" id="bkmrk-json"><span class="language-label">json</span></div>```json
    {
        "colleague_id": 75
    }

```

(درخواست از طرف کاربری در شعبه ۲ ارسال شده است)

- **Action:**

1. یک آرایه `insert` با مقادیر `branch: 2` و `colleague_id: 75` ساخته می‌شود.
2. `DB::table('charter_pledgers')->insert($insert)` اجرا می‌شود.

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