joshluongo / laravel-aus
Support for down under.
Requires
- php: ^8.1
- illuminate/contracts: ^11.0||^12.0||^13.0
- nesbot/carbon: ^2.72||^3.0
- spatie/laravel-package-tools: ^1.93
Requires (Dev)
- fakerphp/faker: ^1.9.1
- larastan/larastan: ^3.0
- laravel/pint: ^1.14
- nunomaduro/collision: ^8.8
- orchestra/testbench: ^8.0|^9.2|^10.0|^11.0
- pestphp/pest: ^2.1|^3.1|^4.0
- pestphp/pest-plugin-arch: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan-deprecation-rules: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- spatie/laravel-ray: ^1.35
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
A small collection to classes to assist with making Laravel applications for the Australian market.
Installation
You can install the package via composer:
composer require joshluongo/laravel-aus
Optionally, you can publish the translations using
php artisan vendor:publish --tag="aus-translations"
Usage
Faker
// Register in your seeder file public function configure(): OrganisationFactory|static { // Inject ABN and ACN providers. $this->faker->addProvider(new \LuongoLabs\LaravelAus\Fakers\AbnAcnProvider($this->faker)); return $this; }
Validation
Validator::make($request->all(), [ 'abn' => new \LuongoLabs\LaravelAus\Rules\Abn(), 'acn' => new \LuongoLabs\LaravelAus\Rules\Acn(), ])->validate();
Financial years
Australian financial years run from 1 July to 30 June and are named by the year they end in. A date's financial year is judged in its own timezone.
use Carbon\CarbonImmutable; use LuongoLabs\LaravelAus\Dates\FinancialYear; $date = CarbonImmutable::parse('2026-10-17', 'Australia/Sydney'); $date->financialYear(); // FinancialYear for FY2026-27 $date->financialYear()->label(); // "FY2026-27" $date->financialYear()->shortLabel(); // "FY27" $date->startOfFinancialYear(); // 2026-07-01 00:00:00 $date->endOfFinancialYear(); // 2027-06-30 23:59:59.999999 FinancialYear::current('Australia/Sydney'); FinancialYear::fromDate(new DateTimeImmutable('2026-06-30'))->endYear; // 2026 (new FinancialYear(2027))->start('Australia/Sydney'); // 2026-07-01 00:00:00 (new FinancialYear(2027))->contains($date); // true
The financialYear(), startOfFinancialYear() and endOfFinancialYear() macros are registered on Carbon and CarbonImmutable by the service provider. Like Carbon's own startOf… methods, the start and end methods change a mutable Carbon in place and return a new instance from CarbonImmutable.
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.