hireatlas/super-funds

Pull the latest list of superannuation funds directly from the Australian Government, right into your Laravel application.

1.0.0 2023-12-05 23:10 UTC

This package is auto-updated.

Last update: 2024-05-06 00:03:52 UTC


README

GitHub Tests Action Status Latest Version on Packagist Total Downloads

This package is a fairly lightweight Laravel wrapper around the service provided by the Australian government that lists all superannuation funds and products by their identifier (USI).

You can find the download here, and structural information about the download here.

We download the text file from this URL, then parse it into some DTOs which you can then save in your database, or use however you wish.

Installation

composer require hireatlas/super-funds

This package supports Laravel 10+, and PHP 8.1+.

Usage

Fetching the list of super funds as DTOs

To fetch the list of current super funds, you can call the fetch() method on the SuperFunds class. This will return a Collection of SuperFundDTO objects.

use Atlas\SuperFunds\SuperFunds;

/** @var SuperFunds $superFundsFetcher */
$superFundsFetcher = app(SuperFunds::class);

$superFunds = $superFundsFetcher->fetch();

dd($superannuationFunds);

Persisting the list of super funds as Eloquent models to your database

The package publishes a migration to store the super funds as Eloquent models in your database, so be sure to run php artisan migrate first before running the below.

To fetch and persist the list of current super funds to the database, you can call the persist() method on the SuperFunds class.

use Atlas\SuperFunds\SuperFunds;

/** @var SuperFunds $superFundsFetcher */
$superFundsFetcher = app(SuperFunds::class);

$superannuationFunds = $superFundsFetcher->persist();

dd($superannuationFunds);

Using a custom Eloquent model

You can use a custom Eloquent model by calling the useModel() method on the SuperFunds class. You should call this from the boot() method in your App\Providers\AppServiceProvider.

use App\Models\SuperFund as CustomSuperFundModel;
use Atlas\SuperFunds\SuperFunds;

public function boot() {
    SuperFunds::useModel(CustomSuperFundModel::class);
}

Disabling migrations

If you don't wish to use the default migration, or don't wish to persist models at all, then you can call the ignoreMigrations() method on the SuperFunds class. You should call this from the boot() method in your App\Providers\AppServiceProvider.

use Atlas\SuperFunds\SuperFunds;

public function boot() {
    SuperFunds::ignoreMigrations();
}

Regularly fetching the current list via task scheduling

The package includes both a command and a job for you to invoke from your App\Console\Kernel. They're equivalent, so use whichever method your prefer.

To avoid overloading the upstream service, please pick a random time of the day to fetch the list.

use Atlas\SuperFunds\Jobs\UpdateSuperFunds;

$schedule->command('super-funds:update')->dailyAt('01:23');
// OR
$schedule->job(new UpdateSuperFunds)->dailyAt('01:23');

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.