Requirements
Before installing Laravel Brick Money, ensure your system meets these requirements:Install via Composer
Install Laravel Brick Money using Composer:The package will automatically register its service provider and publish necessary assets thanks to Laravel’s package auto-discovery feature.
What Gets Installed
When you install the package, the following components are automatically registered:Service Provider
Service Provider
The
Devhammed\LaravelBrickMoney\Provider class is automatically registered and provides:- Configuration file registration
- Blade directive registration (
@money,@currency) - Blade component registration (
<x-money>,<x-currency>) - Request macro registration (
request()->money(),request()->currency()) - Livewire synthesizer registration (if Livewire is installed)
Helper Functions
Helper Functions
Two global helper functions become available:
Eloquent Casts
Eloquent Casts
Model casts for storing money in databases:
AsIntegerMoney- Stores minor units (recommended)AsDecimalMoney- Stores major unitsAsCurrency- Stores currency codes
Validation Rules
Validation Rules
Custom validation rules:
MoneyRule- Validates monetary amountsCurrencyRule- Validates currency codes
Verify Installation
Verify the package is installed correctly by running:Testing the Installation
Create a test route to verify everything works:Visit the Route
Start your development server and visit the route:Navigate to
http://localhost:8000/test-moneyInstall Optional Dependencies
PHP Intl Extension
For locale-based formatting, install the Intl extension:Livewire (Optional)
If you’re using Livewire, the package automatically registers synthesizers forMoney and Currency objects:
Updating the Package
To update to the latest version:Troubleshooting
Class not found error
Class not found error
If you see “Class ‘Devhammed\LaravelBrickMoney\Money’ not found”:
Service provider not registering
Service provider not registering
If the service provider isn’t auto-registered, manually add it to
config/app.php:config/app.php
Helper functions not available
Helper functions not available
Ensure Composer’s autoload files are being loaded in your Then run:
composer.json:composer.json
Next Steps
Now that Laravel Brick Money is installed, learn how to configure it:Configuration
Configure default currency, minor unit handling, and customize currency definitions.