PHPackages                             agri/departments - 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. agri/departments

ActiveLibrary

agri/departments
================

Sync departments from the AgriServ central system to your Laravel application

00PHP

Since Jul 15Pushed 1mo agoCompare

[ Source](https://github.com/AbdullahQ95/AgriservDepartments)[ Packagist](https://packagist.org/packages/agri/departments)[ RSS](/packages/agri-departments/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Agri Departments
================

[](#agri-departments)

Receive and sync department updates from the AgriServ central system into your Laravel application.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11+

Installation
------------

[](#installation)

```
composer require agri/departments
```

Publish the config file:

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

Add the secret key to your `.env`:

```
SSO_SECRET_KEY=your-secret-key
```

How It Works
------------

[](#how-it-works)

Once installed, the package registers a single endpoint:

```
POST /api/departments/sync

```

The central AgriServ system calls this endpoint whenever a department's `manager_id` changes, passing the department `key` and the new `manager_id`.

**Request:**

```
POST /api/departments/sync
X-Token: your-secret-key

{
    "key": "finance",
    "manager_id": "098765"
}

```

**Responses:**

StatusMeaning`200`Department updated successfully`401`Invalid or missing `X-Token``404`Department key not found`422`Validation failedHandling the Sync
-----------------

[](#handling-the-sync)

The package does **not** manage your database. You are responsible for updating the department by extending the base controller.

**1. Create your controller:**

```
