Download the PHP package osoobe/laravel-utilities without Composer
On this page you can find all versions of the php package osoobe/laravel-utilities. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-utilities
Laravel Utilities
A collection of Eloquent model traits, static helper classes, migration Blueprint macros, a generic AJAX data endpoint, and a base Artisan command — designed to eliminate boilerplate across Laravel applications.
Install
The service provider is auto-discovered. No manual registration needed.
Table of Contents
- Migration Blueprint Macros
- Eloquent Model Traits
- Helper Classes
- Generic AJAX Resource Endpoint
- Custom Validators
- Base Artisan Command
- Use Cases
- Testing
Migration Blueprint Macros
The package registers Blueprint macros that add common column groups with a single call.
Location columns
Coordinate columns
Userstamp columns
Tracks which user created and last edited a record using polymorphic morphs, supporting multi-model auth setups.
Active status column
Eloquent Model Traits
Active — Active/inactive record scopes
Requires an is_active column (added via $table->isActive()).
HasVerified — Verified record scopes
Requires a verified column.
IsDefault — Default record scopes
Requires an is_default column.
Sorted — Sort order scope
Requires a sort_order column.
HasSlug — Slug-based lookup
HasEmail — Email verification scopes
Userstamp — Auto-fill creator/editor on save
Requires userstamp() Blueprint macro columns. Automatically sets creator_* on create and editor_* on update using Auth::user().
TimeDiff — Date/time scopes and human-readable diffs
HasFullTextSearch / FullTextSearchTrait — MySQL FULLTEXT search
Add the FULLTEXT index in your migration using MigrationHelper, then apply the trait to the model.
AdvanceWhereQuery — Conditional where clauses
ModelDefaultTrait — Set default values before create
SEO — SEO attribute contract
Lang — Locale-based scopes
Requires a lang column and an App\Language model in the consuming app.
Helper Classes
All helpers use static methods and require no instantiation.
Utilities
General-purpose utilities for objects, arrays, math, and strings.
Str
Extends Illuminate\Support\Str — all built-in Laravel string methods are available.
FormatHelper
Renders URLs, emails, and phone numbers as plain text, HTML anchors, or Markdown links.
Supported $format values: 'html', 'markdown', 'string' (default).
Date
MigrationHelper
PhoneNumberHelper
Validation pattern is configurable via config('validation.phone.pattern').
ImageHelper
MapBoxHelper
GoogleMapsHelper
Generic AJAX Resource Endpoint
The package provides a single parameterized route that serves model data to front-end libraries (Bootstrap Table, Select2) without writing per-model controllers or routes.
Route: GET /api/resources/{slug}/{format}
Name: api.resource.get
Formats: bst (Bootstrap Table, default), select2
1. Publish and configure api-endpoints.php
Copy the config file to your application:
Then define each resource in config/api-endpoints.php:
2. Call the endpoint from the front end
Bootstrap Table:
Response shape:
Select2:
Response shape:
Query parameters supported
| Parameter | Description |
|---|---|
term / search |
Text search (FULLTEXT or LIKE depending on config) |
sort |
Column to sort by (default: id) |
order |
asc or desc (default: asc) |
limit |
Number of records |
offset |
Pagination offset (Bootstrap Table) |
paginate |
true to enable cursor pagination (Select2) |
Custom Validators
Two validation rules are registered automatically.
phone
Override the pattern in config/validation.php:
password
Requires the consuming app to publish a config/validation.php with:
Base Artisan Command
Extend Osoobe\Utilities\Console\Command to get automatic execution timing.
Use Cases
Multi-tenant CRM with creator tracking
Use Userstamp + Active to track who created/edited every record and filter inactive ones:
Job board with expiry and full-text search
Use TimeDiff + FullTextSearchTrait for a job listing model:
Geocoding an address on model save
Combine MapBoxHelper with a model observer or ModelDefaultTrait:
Searchable admin panel with Bootstrap Table + Select2
Register your models in config/api-endpoints.php and drop in the JS widgets — no backend changes needed when adding new searchable models.
Storing user avatar uploads as base64
SEO-ready product pages
Testing
Tests extend Osoobe\Utilities\Tests\TestCase (Orchestra Testbench), which auto-registers the service provider.
Changelog
Please see CHANGELOG for recent changes.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.