Search by

joshluongo / laravel-aus

joshluongo

Support for down under.

Package info

github.com/joshluongo/laravel-aus

pkg:composer/joshluongo/laravel-aus

Statistics

Installs: 118

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 1

v1.3.0 2026-10-17 04:50 UTC

This package is auto-updated.

Last update: 2026-10-17 04:51:17 UTC


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.