smart-till / core
SMART TiLL core Filament modules
Requires
- php: ^8.2
- filament/filament: ^5.0
- laravel/framework: ^12.0
- laravel/sanctum: ^4.0
- league/iso3166: ^4.3
- livewire/livewire: ^4.0
- pragmarx/countries: ^1.0
Requires (Dev)
README
smart-till/core is the shared business/domain layer for SMART TiLL Server and SMART TiLL POS.
This package centralizes:
- Filament Resources, Pages, Relation Managers, and Widgets
- Core Eloquent Models
- Domain Enums
- Domain Observers
- Shared Services (geo bootstrap, permissions bootstrap, settings bootstrap, units bootstrap)
- Shared routes/views used by both server and POS
- Shared schema migrations for core tables/columns
The goal is one implementation for both projects so behavior stays aligned.
What This Package Actually Does
When installed in a host Laravel app, this package:
- Registers
SmartTill\Core\Providers\CoreServiceProvider - Loads package migrations from
database/migrationsinside this package - Loads package views (
resources/views) - Loads package routes from
routes/web.php(only ifpublic.receiptroute is not already registered) - Registers Livewire component:
product-search - Registers morph-map compatibility for core/app aliases
- Attaches core observers to core models
- Provides installer commands to bootstrap required data
Compatibility Matrix
- PHP:
^8.2 - Laravel:
^12.0 - Filament:
^5.0 - Livewire:
^4.0
From package composer.json:
filament/filamentlaravel/frameworklaravel/sanctumleague/iso3166livewire/livewirepragmarx/countries
Host App Requirements
Before installation:
- Host app has
App\Models\Store storestable exists- Host app uses Filament tenancy with
Storetenant model - Host app has a
Storepanel that discovers package resources/pages
If these are missing, install command will fail fast with explicit errors.
Installation
Option A: VCS (Recommended for staging/production)
In host app composer.json:
{
"repositories": [
{
"type": "vcs",
"url": "https://github.com/SMART-DADDY/core"
}
],
"require": {
"smart-till/core": "^1.0"
}
}
Then:
composer update smart-till/core --with-all-dependencies --no-interaction php artisan core:install --no-interaction php artisan optimize:clear
Option B: Local Path (development only)
In host app composer.json:
{
"repositories": [
{
"type": "path",
"url": "../core",
"options": {
"symlink": true
}
}
],
"require": {
"smart-till/core": "*@dev"
}
}
Then:
composer update smart-till/core --no-interaction php artisan core:install --no-interaction
Installer Commands
php artisan core:install
Runs on default DB connection and does:
- Validates
App\Models\Store - Validates
storestable exists - Runs
php artisan migrate --force --no-interaction - Bootstraps countries/currencies/timezones
- Bootstraps store settings defaults
- Bootstraps universal units
- Bootstraps core permissions and super-admin role mapping
php artisan native:core:install
For NativePHP sqlite runtime:
- Validates
App\Models\Store - Validates
native:migratecommand exists - Runs
php artisan native:migrate --force --no-interaction - Validates
storesexists onnativephpconnection - Runs same bootstrap services on
nativephpconnection
Host Panel Wiring (Required)
Your Filament Store panel must discover package resources/pages.
Example pattern:
use ReflectionClass; use SmartTill\Core\Providers\CoreServiceProvider; use SmartTill\Core\Http\Middleware\SetTenantTimezone as CoreSetTenantTimezone; $coreSrcPath = dirname((new ReflectionClass(CoreServiceProvider::class))->getFileName(), 2); ->discoverResources(in: $coreSrcPath.'/Filament/Resources', for: 'SmartTill\\Core\\Filament\\Resources') ->discoverPages(in: $coreSrcPath.'/Filament/Pages', for: 'SmartTill\\Core\\Filament\\Pages') ->tenantMiddleware([CoreSetTenantTimezone::class], isPersistent: true)
Without tenant timezone middleware, created_at/updated_at can render in wrong timezone.
Config
The package reads:
config('smart_till.reference_on_create', true)
If true:
- Store-scoped reference values are auto-assigned for resources having
referencecolumns.
Recommended host config file:
<?php return [ 'reference_on_create' => true, ];
Save as: config/smart_till.php
Migrations Included In This Package
Current package migrations:
2026_02_25_000002_create_core_tables.php2026_02_26_000003_add_store_user_cash_columns.php2026_03_02_000010_add_local_id_to_sync_tables.php2026_03_02_104300_add_reference_to_sync_tables.php
These migrations are idempotent-style guarded with Schema::hasTable/hasColumn checks where appropriate.
Important: Existing Projects With Legacy Data
This package ships foundational schema. Project-specific data correction/backfill migrations may exist in host app (for example polymorphic type normalization and reference backfills).
If your host app already has production data, you should:
- Run package install/migrations
- Run host app custom backfill/fix migrations
- Verify key datasets (transactions, payments, references, dashboard stats)
Do not assume package migration alone backfills historical data.
Morph Map / Polymorphic Compatibility
Core provider registers compatibility map for both app and core class names:
App\Models\Customer<->SmartTill\Core\Models\CustomerApp\Models\Supplier<->SmartTill\Core\Models\SupplierApp\Models\Sale<->SmartTill\Core\Models\SaleApp\Models\PurchaseOrder<->SmartTill\Core\Models\PurchaseOrderApp\Models\Payment<->SmartTill\Core\Models\PaymentApp\Models\Transaction<->SmartTill\Core\Models\Transaction
This is required because historical records can contain either alias.
Observer Behavior
Core provider wires domain observers, including:
- Product/variation/stock/sale/payment/transaction lifecycle observers
- Store-scoped reference observer across multiple entities
Because this is centralized in package boot, behavior is shared between Server and POS when both consume the same core version.
Versioning / Release Policy
For production:
- Tag this repository (
vX.Y.Z) - Pin host apps to that tag/range
- Avoid
dev-mainin production
Recommended:
"smart-till/core": "^1.0"
Not recommended for production:
"smart-till/core": "dev-main"
Upgrade Procedure
- Update package version in host app
composer update smart-till/core --with-all-dependencies --no-interactionphp artisan core:install --no-interactionphp artisan optimize:clear- Run smoke tests:
- Sales create/print
- Purchase order flows
- Payment flows
- Customer/supplier transaction links
- Dashboard widgets
- Tenant timezone rendering
Testing This Package
From package root:
./vendor/bin/pest
Or single file:
./vendor/bin/pest tests/Feature/CorePaymentPrintRouteGuardTest.php
Troubleshooting
Missing required model: App\Models\Store
Create host model:
php artisan make:model Store
Missing required table: stores
Run host migrations that create stores, then rerun installer.
Package installed but resources/pages not visible
- Ensure panel
discoverResources/discoverPagesincludes core namespace/path - Clear cache:
php artisan optimize:clear
Wrong timezone display in Filament dates
- Ensure tenant middleware includes
SetTenantTimezone - Ensure store has valid
timezone_idand related timezone row - Ensure date columns call
->timezone(fn () => Filament::getTenant()?->timezone?->name ?? 'UTC')
Notes For Contributors
- Keep business logic in
corewhen shared between Server and POS. - Keep host-app-only logic in host app.
- Add tests for behavior compatibility, especially around morph aliases and route/url generation.
- Avoid introducing breaking changes without migration strategy and release notes.