tipoff/support
tipoff/support provides shared Laravel/PHP utilities for Tipoff packages—common helpers, conventions, and support code used across the ecosystem. Intended as an internal foundation dependency to keep other packages consistent and easier to maintain.
Installation
composer require tipoff/support
Add to config/app.php under providers:
Tipoff\Support\SupportServiceProvider::class,
First Use Case: Validation & Form Handling
The package provides a Support facade for common ecommerce validation and form logic. Start with:
use Tipoff\Support\Facades\Support;
// Basic validation example
$validated = Support::validate(request(), [
'email' => 'required|email',
'quantity' => 'integer|min:1'
]);
Key Entry Points
Support (for core utilities)HasSupport (for models)support() helper functionExtend models with support traits for reusable logic:
use Tipoff\Support\Traits\HasSupport;
class Product extends Model
{
use HasSupport;
// Automatically gains support methods
public function isAvailableForPurchase()
{
return $this->isSupportable() && $this->stock > 0;
}
}
Use the facade for ecommerce-specific validation:
$data = Support::sanitize([
'price' => '19.99',
'sku' => 'PROD-123'
], [
'price' => 'numeric|min:0',
'sku' => 'string|max:50|alpha_dash'
]);
Leverage built-in payment helpers:
$payment = Support::processPayment($order, [
'method' => 'stripe',
'amount' => $order->total,
'currency' => 'USD'
]);
Standardize API responses:
return Support::apiResponse([
'success' => true,
'data' => $product
]);
Service Container: Bind custom support services:
$this->app->bind('support.logger', function () {
return new CustomSupportLogger();
});
Observers: Use Support::observe() for model events:
Support::observe(Order::class, function ($order) {
// Post-save logic
});
$this->mock(Support::class)->shouldReceive('validate')
->once()
->andReturn($validatedData);
Deprecated Methods
Support::old() was renamed to Support::flash() in v1.2+. Check changelog for breaking changes.Overzealous Autoloading
class Product extends Model
{
protected $disableSupportTraits = true;
}
Payment Gateway Assumptions
'payment' => [
'default' => 'custom_gateway',
'gateways' => [
'custom_gateway' => CustomGateway::class,
],
],
Enable Verbose Logging
Support::setLogLevel('debug');
Check for Silent Failures
try {
$result = Support::processOrder($order);
} catch (\Tipoff\Support\Exceptions\SupportException $e) {
Support::logError($e, ['order_id' => $order->id]);
}
Custom Validators Extend the validator:
Support::extendValidator('ecommerce', function ($attribute, $value, $parameters) {
return str_starts_with($value, 'PROD-');
});
Hooks System Register custom hooks:
Support::hook('order.created', function ($order) {
// Post-order logic
});
Configuration Overrides Publish config and override defaults:
php artisan vendor:publish --provider="Tipoff\Support\SupportServiceProvider" --tag="config"
Cache Validation Rules
$rules = Support::cachedRules('product', 3600); // Cache for 1 hour
Lazy-Load Heavy Dependencies
Support::lazyLoad('payment_gateway', function () {
return new HeavyPaymentGateway();
});
How can I help you explore Laravel packages today?