This project has been archived, and no further support will be provided. Anyone is welcome to fork the project to continue development., (*1)
laravel-deputy
Laravel package for interacting with the Deputy API. Deputy is a powerful business management system, available from https://www.deputy.com., (*2)
This package is provided AS-IS, with no guarantee of functionality or support. This package is not meant to work for every use case. More information may be found in this repository's LICENSE file., (*3)
Some basic instructions are provided below., (*4)
Installation
composer require blitheness/laravel-deputy dev-master
, (*5)
php artisan vendor:publish
(then enter number for Blitheness\Deputy\DeputyServiceProvider), (*6)
Configuration
Either update config/deputy.php to change the 'url' and 'token' values, or set 'DEPUTY_URL' and 'DEPUTY_TOKEN' values in your .env file., (*7)
The URL is the Deputy subdomain that your company is using, such as "mycompany.eu.deputy.com", without any "http://", "https://", or any trailing slashes., (*8)
The token is your Deputy API 'Permanent Token', which may be created by a System Administrator in your organisation. An authorised user may generate a token by following the instructions in the Deputy API documentation: https://www.deputy.com/api-doc/API/Authentication, (*9)
Usage
Resources
- Company
- Employee
- EmployeeAgreement
- EmployeeContract
- EmployeeWorkplace
- OperationalUnit
- User (read-only)
Facades
To make use of a Deputy 'resource', use a real-time Facade., (*10)
Add this to the top of your controller use Facades\Blitheness\Deputy\Models\RESOURCE_NAME;
where RESOURCE_NAME is a resource from the list above., (*11)
Retrieving Data
Known ID
$result = Resource::find(ID)
, (*12)
Where Resource is a resource from the list above, and ID is the ID of the resource in Deputy that you are attempting to find., (*13)
Searching
To search, use the 'search' method on that resource's real-time facade:, (*14)
$results = Resource::search('FieldName', 'eq', 'Value')->get();
, (*15)
More than one condition may be used per query by chaining the search calls together, such as:, (*16)
$results = Resource::search('FieldName', 'eq', 'Value')->search('Active', 'eq', '1')->get();
, (*17)
Updating Resources
Model attributes
To update a resource, it must not be a read-only resource., (*18)
First, retrieve the resource you wish to modify, for example:, (*19)
$resource = Employee::find(123);
, (*20)
Secondly, change the desired attribute(s) on the model:, (*21)
$resource->FirstName = "New First Name";
, (*22)
Finally, call the save method on the model:, (*23)
$resource->save()
, (*24)
Background tasks (Jobs)
Remove employee from location
To disassociate an employee from a location, you must know the employee's ID and the ID of the location., (*25)
Then, one of the following jobs may be dispatched:, (*26)
Blitheness\Deputy\Jobs\DisassociateEmployee
, (*27)
Firstly, include this in the controller file before your class declaration:, (*28)
use Blitheness\Deputy\Jobs\DisassociateEmployee;
, (*29)
Then, write the following where you would like to dispatch the job:, (*30)
DisassociateEmployee::dispatch($deputyId, $locationId);
, (*31)
where deputyId is the Employee ID, and locationId is the ID of the location that they are to be removed from., (*32)