blackboxcode/pando-employee-bundle
Installation
composer require blackboxcode/pando-employee-bundle
Add to config/bundles.php:
BlackBoxCode\PandoEmployeeBundle\PandoEmployeeBundle::class => ['all' => true],
Publish Configuration
php artisan vendor:publish --provider="BlackBoxCode\PandoEmployeeBundle\PandoEmployeeProvider"
Edit config/pando_employee.php to match your HR system API credentials.
First Use Case: Fetch Employee Data Inject the service into a controller or command:
use BlackBoxCode\PandoEmployeeBundle\Service\EmployeeService;
public function __construct(private EmployeeService $employeeService) {}
public function getEmployeeData(int $employeeId) {
$employee = $this->employeeService->fetchEmployee($employeeId);
return view('employee.profile', compact('employee'));
}
Environment Setup
Ensure .env has:
PANDO_API_KEY=your_api_key_here
PANDO_API_SECRET=your_api_secret_here
PANDO_BASE_URL=https://your-hr-system-api.com
CRUD Operations
// Create
$newEmployee = $this->employeeService->create([
'first_name' => 'John',
'last_name' => 'Doe',
'email' => 'john@example.com',
]);
// Read
$employee = $this->employeeService->fetch(123);
// Update
$this->employeeService->update(123, ['department' => 'Engineering']);
// Delete
$this->employeeService->delete(123);
Bulk Operations
// Sync departments
$this->employeeService->syncDepartments([
['id' => 1, 'name' => 'Marketing'],
['id' => 2, 'name' => 'Sales'],
]);
Event-Driven Integration
Listen for employee events in EventServiceProvider:
protected $listen = [
'BlackBoxCode\PandoEmployeeBundle\Events\EmployeeCreated' => [
'App\Listeners\LogEmployeeCreation',
],
];
HasMany relationships to link employees to models:
public function employees() {
return $this->hasMany(Employee::class)->using(EmployeeModel::class);
}
$middleware = [
\BlackBoxCode\PandoEmployeeBundle\Http\Middleware\RateLimit::class,
];
Cache::remember:
$employee = Cache::remember("employee_{$id}", now()->addHours(1), function() use ($id) {
return $this->employeeService->fetch($id);
});
API Key Validation
PANDO_API_KEY is missing.AppServiceProvider:
if (!config('pando_employee.api_key')) {
throw new \RuntimeException('Pando API key not configured.');
}
Data Mismatch
mapResponse in config/pando_employee.php:
'field_mapping' => [
'employee_id' => 'id',
'full_name' => 'first_name',
],
Webhook Verification
PandoWebhookMiddleware:
use BlackBoxCode\PandoEmployeeBundle\Http\Middleware\VerifyPandoSignature;
$middleware = [
VerifyPandoSignature::class,
];
Enable API Logging
Add to config/pando_employee.php:
'debug' => env('APP_DEBUG', false),
Logs will appear in storage/logs/pando.log.
Mock API Responses
Use PandoEmployeeBundle's testing trait:
use BlackBoxCode\PandoEmployeeBundle\Tests\TestCase;
public function testEmployeeFetch() {
$this->mockPandoResponse('employee', ['id' => 1, 'name' => 'Test']);
$employee = $this->employeeService->fetch(1);
$this->assertEquals('Test', $employee['name']);
}
Custom Fields
Extend the Employee model:
namespace App\Models;
use BlackBoxCode\PandoEmployeeBundle\Models\Employee as BaseEmployee;
class Employee extends BaseEmployee {
protected $appends = ['custom_field'];
public function getCustomFieldAttribute() {
return $this->attributes['custom_field'] ?? null;
}
}
Custom API Endpoints
Create a decorator for EmployeeService:
namespace App\Services;
use BlackBoxCode\PandoEmployeeBundle\Service\EmployeeService as BaseService;
class EmployeeService extends BaseService {
public function customEndpoint($params) {
return $this->client->request('GET', '/custom', $params);
}
}
Bind in AppServiceProvider:
$this->app->bind(
\BlackBoxCode\PandoEmployeeBundle\Service\EmployeeService::class,
\App\Services\EmployeeService::class
);
Webhook Handlers
Register custom handlers in config/pando_employee.php:
'webhook_handlers' => [
'employee.created' => \App\Listeners\HandleEmployeeCreated::class,
'department.updated' => \App\Listeners\SyncDepartmentCache::class,
],
How can I help you explore Laravel packages today?