innobrain / laravel-onoffice-adapter
Laravel package to joyfully interact with the onOffice API
Fund package maintenance!
Innobraingmbh
Installs: 21 667
Dependents: 2
Suggesters: 0
Security: 0
Stars: 5
Watchers: 2
Forks: 1
Open Issues: 2
pkg:composer/innobrain/laravel-onoffice-adapter
Requires
- php: ^8.2
- illuminate/contracts: ^10.0||^11.0||^12.0
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- driftingly/rector-laravel: ^2.0.0
- guzzlehttp/guzzle: ^7.8
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.1.1||^7.10.0
- orchestra/testbench: ^9.0.0||^8.22.0
- pestphp/pest: ^3.0
- pestphp/pest-plugin-arch: ^3.0
- pestphp/pest-plugin-laravel: ^3.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- rector/rector: ^2.0.0
- dev-main
- v1.11.1
- v1.11.0
- v1.10.0
- v1.9.4
- v1.9.3
- v1.9.2
- v1.9.1
- v1.9.0
- v1.8.2
- v1.8.1
- v1.8.0
- v1.7.2
- v1.7.1
- v1.7.0
- v1.6.0
- v1.5.10
- v1.5.9
- v1.5.8
- v1.5.7
- v1.5.6
- v1.5.5
- v1.5.4
- v1.5.3
- v1.5.2
- v1.5.1
- v1.5.0
- v1.4.5
- v1.4.4
- v1.4.3
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1.0
- v1.0.0
- v0.13.6
- v0.13.5
- v0.13.4
- v0.13.3
- v0.13.2
- v0.13.1
- v0.13.0
- v0.12.4
- v0.12.3
- v0.12.2
- v0.12.1
- v0.12.0
- v0.11.0
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.1
- v0.9.0
- v0.8.6
- v0.8.5
- v0.8.4
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.7
- v0.7.6
- v0.7.5
- v0.7.4
- v0.7.3
- v0.7.2
- v0.7.1
- v0.7.0
- v0.6.0
- v0.5.4
- v0.5.3
- v0.5.2
- v0.5.1
- v0.5.0
- v0.4.1
- v0.4.0
- v0.3.0
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.0
- dev-feat/laravel-pagination
- dev-hotfix/search-criteria
- dev-push-phpstan
- dev-docs
- dev-after
- dev-concurrency
This package is auto-updated.
Last update: 2026-01-28 06:44:01 UTC
README
A fluent query builder for the onOffice API, designed to feel like Eloquent.
Features
- ORM-like Querying - Use familiar Laravel Eloquent-style methods like
where(),select(),orderBy() - Comprehensive Repositories - Access estates, addresses, activities, search criteria, files, and more
- Pagination & Chunking - Handle large datasets with
each(),limit(), and automatic pagination - Middlewares - Insert custom logic before requests for logging, modification, or validation
- Testing Support - Built-in fake system with factories for easy unit testing
- File Management - Upload, chunk, and link files with onOffice
Installation
composer require innobrain/laravel-onoffice-adapter
Add your onOffice API credentials to .env:
ON_OFFICE_TOKEN=your-token
ON_OFFICE_SECRET=your-secret
For advanced configuration (retry settings, custom headers), publish the config file:
php artisan vendor:publish --tag="laravel-onoffice-adapter-config"
Usage
Basic Queries
use Innobrain\OnOfficeAdapter\Facades\EstateRepository; // Get all estates $estates = EstateRepository::query()->get(); // Find by ID $estate = EstateRepository::query()->find(123); // Get first result $estate = EstateRepository::query()->first(); // Count results $count = EstateRepository::query()->count();
Building Queries
Chain methods to filter, sort, and limit results:
$estates = EstateRepository::query() ->select(['Id', 'kaufpreis', 'lage']) ->where('status', 1) ->where('kaufpreis', '<', 500000) ->orderByDesc('kaufpreis') ->limit(10) ->get();
Available Methods
| Method | Description |
|---|---|
select($fields) |
Fields to retrieve |
where($field, $op, $value) |
Filter by condition |
whereIn($field, $values) |
Filter by array of values |
whereLike($field, $pattern) |
Pattern matching |
whereBetween($field, $min, $max) |
Range filter |
orderBy($field) |
Sort ascending |
orderByDesc($field) |
Sort descending |
limit($n) |
Max results |
offset($n) |
Skip results |
Large Datasets
Handle large datasets without memory issues using chunked processing:
EstateRepository::query() ->each(function (array $estates) { foreach ($estates as $estate) { // Process chunk } });
Available Repositories
| Repository | Description |
|---|---|
EstateRepository |
Real estate properties |
AddressRepository |
Contacts and addresses |
ActivityRepository |
Activity logs |
SearchCriteriaRepository |
Buyer search profiles |
FieldRepository |
Field metadata |
FileRepository |
File uploads and downloads |
FilterRepository |
Saved filters |
RelationRepository |
Record relationships |
SettingRepository |
System settings |
MarketplaceRepository |
Marketplace integration |
LinkRepository |
URL links |
LogRepository |
Log entries |
MacroRepository |
Macros |
LastSeenRepository |
Recently viewed records |
File Uploads
$tmpUploadId = FileRepository::upload() ->save(base64_encode($fileContent)); FileRepository::upload()->link($tmpUploadId, [ 'module' => 'estate', 'relatedRecordId' => '12345', ]); // Or upload in blocks and link in one call FileRepository::upload() ->uploadInBlocks() ->saveAndLink(base64_encode($fileContent), [ 'module' => 'estate', 'relatedRecordId' => '12345', ]);
Creating Activities
ActivityRepository::query() ->addressIds($recordIds) ->estateId($estateId) ->create([ 'datetime' => $event->getDateFormatted(), 'actionkind' => 'Newsletter', 'actiontype' => 'Hard Bounce', 'note' => $message, ]);
Middlewares
Inject custom logic before each request:
use Innobrain\OnOfficeAdapter\Facades\BaseRepository; use Innobrain\OnOfficeAdapter\Dtos\OnOfficeRequest; BaseRepository::query() ->before(function (OnOfficeRequest $request) { Log::info('Sending request', ['request' => $request->toArray()]); }) ->call(new OnOfficeRequest(/* ... */));
Debugging
// Dump and die BaseRepository::query()->dd()->call(/* ... */); // Dump without stopping BaseRepository::query()->dump()->call(/* ... */); // Record requests and responses BaseRepository::record(); BaseRepository::query()->call(/* ... */); $lastPair = BaseRepository::lastRecorded(); // [OnOfficeRequest, OnOfficeResponse]
Helpers
Use default fields and clean empty values:
use Innobrain\OnOfficeAdapter\Services\OnOfficeService; $estates = EstateRepository::query() ->select(OnOfficeService::DEFAULT_ESTATE_INFO_FIELDS) ->get(); // Remove fields with empty values ("", "0.00", [], null) $estates = clean_elements($estates);
Testing
The package includes a built-in fake system for testing:
use Innobrain\OnOfficeAdapter\Facades\EstateRepository; use Innobrain\OnOfficeAdapter\Facades\Testing\RecordFactories\EstateFactory; EstateRepository::fake(EstateRepository::response([ EstateRepository::page(recordFactories: [ EstateFactory::make()->id(1)->set('kaufpreis', 250000), EstateFactory::make()->id(2)->set('kaufpreis', 300000), ]), ])); $estates = EstateRepository::query()->get(); expect($estates)->toHaveCount(2); EstateRepository::assertSentCount(1);
Prevent Unstubbed Requests
EstateRepository::preventStrayRequests(); EstateRepository::fake(/* ... */); // Any unstubbed request will throw StrayRequestException
Multiple Pages
EstateRepository::fake(EstateRepository::response([ EstateRepository::page(recordFactories: [ EstateFactory::make()->id(1), ]), EstateRepository::page(recordFactories: [ EstateFactory::make()->id(2), ]), ])); $estates = EstateRepository::query()->get(); expect($estates)->toHaveCount(2);
Sequences (Multiple Calls)
EstateRepository::fake([ EstateRepository::response([/* first call */]), EstateRepository::response([/* second call */]), ]); // Or repeat the same response EstateRepository::fake(EstateRepository::sequence( EstateRepository::response([/* ... */]), times: 30, ));
See the Testing Documentation for factories, assertions, and advanced patterns.
Development
composer test # Run tests composer analyse # Static analysis (PHPStan) composer format # Code formatting (Laravel Pint)
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.