ismaildasci / laravel-sapb1-toolkit
Complete business logic toolkit for SAP Business One Service Layer - Eloquent-like ORM, Actions, Builders, DTOs, Caching, Change Tracking, and Local Database Sync
Package info
github.com/ismaildasci/sapb1-laravel-toolkit
pkg:composer/ismaildasci/laravel-sapb1-toolkit
Fund package maintenance!
Requires
- php: ^8.4
- illuminate/contracts: ^11.0||^12.0
- ismaildasci/laravel-sapb1: ^1.0@beta
- spatie/laravel-package-tools: ^1.16
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^10.0.0||^9.0.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- dev-main
- v3.0.0
- v2.9.0
- v2.8.0
- v2.7.0
- v2.6.0
- v2.5.0
- v2.4.0
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.1
- v2.0.0
- v1.5.0
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.1
- v1.0.0
- v1.0.0-beta.3
- v1.0.0-beta.2
- v1.0.0-beta.1
- dev-dependabot/github_actions/dependabot/fetch-metadata-3.0.0
- dev-dependabot/github_actions/ramsey/composer-install-4
This package is auto-updated.
Last update: 2026-03-28 08:12:17 UTC
README
A complete business logic toolkit for SAP Business One Service Layer integration in Laravel. Built on top of laravel-sapb1.
Features
| Component | Count | Description |
|---|---|---|
| Models | 54 | Eloquent-like ORM for SAP B1 entities |
| Actions | 110 | CRUD operations for all SAP B1 entities |
| Builders | 122+ | Fluent document construction |
| DTOs | 145+ | Type-safe data transfer objects |
| Services | 17 | Business logic orchestration |
| Enums | 36 | SAP B1 constants and status codes |
| Commands | 7 | Artisan CLI commands |
| Cache | 2 | Priority-based caching system |
Modules: Sales, Purchase, Inventory, Finance, Business Partner, Production, HR, Admin, Service
Key Capabilities
- Eloquent-like ORM - Query SAP B1 entities with familiar Laravel syntax
- UDF Support - Read/write User Defined Fields on any entity
- Local Caching - Priority-based cache with entity-level configuration
- Change Tracking - Polling-based change detection for SAP entities
- Local Database Sync - Sync SAP data to local database with soft deletes
Requirements
- PHP 8.4+
- Laravel 11.x or 12.x
- laravel-sapb1 ^1.0
Installation
composer require ismaildasci/laravel-sapb1-toolkit
php artisan vendor:publish --tag="sapb1-toolkit-config"
Quick Start
Eloquent-like Models
use SapB1\Toolkit\Models\Sales\Order; $orders = Order::where('DocTotal', '>', 1000) ->where('DocumentStatus', 'bost_Open') ->orderBy('DocDate', 'desc') ->with('partner') ->get(); $order = Order::create([ 'CardCode' => 'C001', 'DocumentLines' => [ ['ItemCode' => 'ITEM001', 'Quantity' => 10, 'Price' => 100], ], ]);
Actions
use SapB1\Toolkit\Actions\Sales\OrderAction; $orderAction = app(OrderAction::class); $order = $orderAction->create([ 'CardCode' => 'C001', 'DocumentLines' => [ ['ItemCode' => 'ITEM001', 'Quantity' => 10, 'Price' => 100], ], ]); $orderAction->close(123);
Builders
use SapB1\Toolkit\Builders\Sales\OrderBuilder; $data = OrderBuilder::create() ->cardCode('C001') ->docDate('2024-01-15') ->addLine(fn ($line) => $line ->itemCode('ITEM001') ->quantity(10) ->price(100) ) ->build();
Services
use SapB1\Toolkit\Services\DocumentFlowService; $flow = app(DocumentFlowService::class); $invoice = $flow->orderToInvoice(123); $delivery = $flow->orderToDelivery(123);
UDF Support (v2.4+)
use SapB1\Toolkit\Models\Sales\Order; $order = Order::find(123); // Read UDFs $value = $order->getUdf('CustomField'); $allUdfs = $order->getUdfs(); // Write UDFs $order->setUdf('CustomField', 'value'); $order->save(); // Builder support $data = OrderBuilder::create() ->cardCode('C001') ->udf('CustomField', 'value') ->build();
Local Cache (v2.5+)
use SapB1\Toolkit\Models\Inventory\Item; // Query-level cache control $item = Item::cache()->find('A001'); // Enable with default TTL $item = Item::cache(600)->find('A001'); // 10 minute TTL $item = Item::noCache()->find('A001'); // Disable cache // Flush cache Item::flushCache(); Item::forgetCached('A001');
Change Tracking (v2.6+)
use SapB1\Toolkit\ChangeTracking\ChangeTracker; $tracker = ChangeTracker::for('Orders') ->primaryKey('DocEntry') ->detectCreated(true) ->detectUpdated(true); $changes = $tracker->poll(); foreach ($changes as $change) { if ($change->isCreated()) { // Handle new order } }
Local Database Sync (v2.7+)
# Create migrations for entities you want to sync php artisan sapb1:sync-setup Items BusinessPartners Orders # Run migrations php artisan migrate # Sync data php artisan sapb1:sync Items # Incremental sync php artisan sapb1:sync Items --full # Full sync with delete detection php artisan sapb1:sync-status # Check sync status
use SapB1\Toolkit\Sync\LocalSyncService; $syncService = app(LocalSyncService::class); // Sync to local database $result = $syncService->sync('Items'); // SyncResult { created: 10, updated: 140, deleted: 0, duration: 1.23s } // Full sync with soft delete detection $result = $syncService->fullSyncWithDeletes('Items'); // Scheduler integration $schedule->command('sapb1:sync Items')->hourly(); $schedule->command('sapb1:sync Items --full')->weekly();
Artisan Commands
| Command | Description |
|---|---|
sapb1:sync {entity} |
Sync SAP data to local database |
sapb1:sync-setup {entities} |
Create sync migrations |
sapb1:sync-status |
Show sync status |
sapb1:watch {entity} |
Watch for entity changes |
sapb1:cache |
Manage entity cache |
sapb1:test-connection |
Test SAP B1 connection |
sapb1:generate |
Generate toolkit components |
Documentation
| Topic | Description |
|---|---|
| Installation | Setup and configuration |
| Models | Eloquent-like ORM |
| Actions | CRUD operations |
| Builders | Fluent document builders |
| DTOs | Data transfer objects |
| Services | Business logic |
| Enums | SAP B1 constants |
| Validation | Laravel validation rules |
| Exceptions | Error handling |
Directory Structure
src/
├── Actions/ # CRUD operations (110 files)
├── Builders/ # Fluent builders (122+ files)
├── DTOs/ # Data Transfer Objects (145+ files)
├── Models/ # Eloquent-like ORM (54 files)
├── Services/ # Business logic (17 files)
├── Enums/ # SAP B1 constants (36 files)
├── Cache/ # Caching infrastructure
├── ChangeTracking/ # Change detection system
├── Sync/ # Local database sync
├── Events/ # Document lifecycle events
├── Exceptions/ # Domain-specific exceptions
├── Rules/ # Laravel validation rules
├── Casts/ # Attribute casts
└── Commands/ # Artisan commands (7 files)
Testing
composer test # Run tests composer analyse # Static analysis composer format # Code formatting
Changelog
See CHANGELOG.md for version history.
Contributing
See CONTRIBUTING.md for guidelines.
Security
Report vulnerabilities via security policy.
License
MIT License. See LICENSE.md for details.
Author: İsmail Daşcı