reliqarts / laravel-logistiq
Multi-purpose tracking/logistics package for Laravel.
Requires
- illuminate/support: ^5.8
- reliqarts/laravel-common: ^2.0@dev
- spatie/laravel-event-projector: ^1.3
Requires (Dev)
- orchestra/testbench: ^3.8
- phpro/grumphp: ^0.15.2
- phpunit/phpunit: ^8.1
- wearejust/grumphp-extra-tasks: ^2.2
This package is auto-updated.
Last update: 2020-12-14 20:16:49 UTC
README
Multi-purpose tracking/logistics package for Laravel
Logistiq is a plug-and-play tracking package which allows you to track any trackable entity (i.e. orders, shipments, etc.) It is highly-configurable and easy to use.
Key Features
- Track any eloquent model through different user-defined statuses.
- Configure one or more events to be fired when a model enters any user-defined status.
- Supports laravel-event-projector in case you're using Event Sourcing (What's this?).
Installation & Usage
-
Install via composer:
composer require reliqarts/laravel-logistiq
-
Configuration & Setup:
-
Publish config file via artisan:
php artisan vendor:publish --tag=reliqarts-logistiq-config
-
The model you intend to track must implement
ReliqArts\Logistiq\Tracking\Contracts\Trackable
or extendReliqArts\Logistiq\Tracking\Models\Trackable
.e.g.
App\Order::class
:<?php // ... use ReliqArts\Logistiq\Tracking\Models\Trackable; class Order extends Trackable { // ... }
-
Create your
Status
model and implement theReliqArts\Logistiq\Tracking\Contracts\Status
contract therein.e.g.
App\Status::class
:<?php // ... use ReliqArts\Logistiq\Utility\Eloquent\Model; use ReliqArts\Logistiq\Tracking\Contracts\Status as LogistiqStatusContract; class Status extends Model implements LogistiqStatusContract { // ... }
-
Configure
event_map
to fire additional events when a particularStatus
is hit.e.g. excerpt from
/config/reliqats-logistiq
:<?php // ... 'event_map' => [ '230c6c51-3b5b-4eea-9ef2-415e4d8fee00' => [ProductShipped::class, ProductMoved::class] ], // ...
Explanation: With the above snipped of code, whenever the Status with identifier
230c6c51-3b5b-4eea-9ef2-415e4d8fee00
is reached by a trackable model theProductShipped
andProductMoved
events will be fired. You have full control over what these events trigger, however each event must expect aTrackable
as the first constructor argument.
-
More on the way... 🚚
License
The MIT License (MIT). Please see LICENSE for more information.