fredlabs / business-units
Business units handler for Laravel 10.* and above.
Requires
- php: >=8.2
- illuminate/auth: ^8.12|^9.0|^10.0|^11.0
- illuminate/database: ^10.0
- illuminate/support: ^10.0
This package is auto-updated.
Last update: 2025-04-24 19:43:37 UTC
README
FredLabs Business Units
Handle business unit within your application.
fredlabs/business-units
is a Laravel package for handling business units in your application. It provides a trait and model for managing business units and includes functionality for automatically updating existing tables with a business_unit_id
column.
Requirements
- Laravel 10.x or higher
- PHP 8.2 or higher
- Composer
Installation, and Usage Instructions
To install the package, use Composer:
composer require fredlabs/business-units
Publish Vendor Files
After successful installation, publish the package's configuration and migration files by running:
php artisan vendor:publish --provider="FredLabs\BusinessUnits\Providers\BusinessUnitServiceProvider"
Edit Configuration
The above command will publish customizable configuration files. In the config/business-units.php file, you can add or modify the fillable attributes in the business_units array to specify which fields you want to use for business unit parameters. For example:
return [ 'fillable' => [ 'name', 'description', 'other_field', ], ];
Migrate Tables
To apply the changes to your existing tables, including adding the business_unit_id column, run:
php artisan migrate
Usage
After installation and migration, you can use the HasBusinessUnit trait in your Eloquent models to enable business unit functionality. Here's how to use it in your models:
use FredLabs\BusinessUnits\Traits\HasBusinessUnit; class User extends Authenticatable { use HasBusinessUnit; }
This trait will allow you to associate business units with your models. Ensure to adjust your models and controllers to handle business unit logic as required.
Authors and Acknowledgments
- FredLabs: Development and maintenance of the package.
- Special thanks to the Laravel community and contributors who provide support and feedback.