# Account Area

# General

# How do I add a Custom CSS File to the account area?

You can add a custom CSS file to the account area by creating a file named `account-area.css` in your public directory.

Example contents where we're overriding the default colours:

```css
:root {
    --bpa-color-primary: deepskyblue;
    --bpa-color-success: forestgreen;
    --bpa-color-warning: darkorange;
    --bpa-color-error: red;
    --bpa-color-helpbox: aliceblue;
    --bpa-color-content-background: ghostwhite;
}
```

<p class="callout info">You can also place this file in your theme if preferred.</p>

# How can I configure the account area?

## ENV Variables

<table border="1" id="bkmrk-variable-default-des" style="border-collapse: collapse; width: 100%; height: 59.5938px;"><colgroup><col style="width: 33.3731%;"></col><col style="width: 33.3731%;"></col><col style="width: 33.3731%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="height: 29.7969px;">**Variable**  
</td><td style="height: 29.7969px;">**Default**  
</td><td style="height: 29.7969px;">**Description**  
</td></tr><tr style="height: 29.7969px;"><td>`AERO_ACCOUNT_AREA_THEME`</td><td>`aerocommerce/account-area`</td><td>Defines the namespace that should be registered as having the views and resources for the account area. This should only be changed under unique circumstances.</td></tr><tr><td>`AERO_ACCOUNT_AREA_LAYOUT`</td><td>`layouts.main`</td><td>Defines the layout that the account area views use. If the layout provided doesn’t exist, account-area::layouts.blank will be used.</td></tr></tbody></table>

## Config File

If you would like to change any of the config values you can publish the config file by running:

```bash
php artisan vendor:publish --provider="Aero\AccountArea\ServiceProvider"
```

<p class="callout info">Once the file is published you will be able to edit it through the config php file created at `/config/aero/account-area.php`.</p>

### `date_format`

This defines the format used when displaying any dates in the account area. `js F Y` by default, e.g. `25/09/2026`.

### `subscription_status_state_class`

Maps subscription status states to specific colors, e.g. `active => success`. So when a subscription has a status with active state, the orb will have the class `bpa-indicator--success` (green).

### `order_status_state_class`

Maps order status states to specific colors, e.g. `active => success`. So when an order has a status with active state, the orb will have the class `bpa-indicator--success` (green).

### `order_status_radio_options`

This defines the order statuses shown in the radio options on the orders page and what order status states they map to.

### `order_years`

This defines the number of previous years to display in the years dropdown on the orders page.

### `page_sections`

This defines the sections that make up each page by default. You can add/edit/remove sections through code, it is not necessary to adjust these values usually.

### `form_sections`

This defines the sections that make up each form by default. You can add/edit/remove sections through code, it is not necessary to adjust these values usually.

### `slots`

This defines the views that are injected into slots by default.

### `links`

This defines the links that should be in the navbar by default. You can add/edit/remove links through code, it is not necessary to adjust these values usually.

# Slots

# What are the available account area slots?

### Navbar

- `navbar.info`

### Addresses

- `addresses.address.card.footer`

### Orders

- `orders.order.card.dispatched`
- `orders.order.card.not-dispatched`
- `order.header.buttons`
- `orders.order.card.header`
- `orders.order.card.footer`

### Subscriptions

- `subscriptions.subscription.card.header`
- `subscriptions.subscription.card.footer`

# How do I inject into account area slots?

Account Area Slots allow you to add content within existing account area pages. The examples below show how to inject a view into the orders page.

For a simple use case, simply provide a view:

```php
\Aero\AccountArea\AccountAreaSlot::inject('order.header.buttons', 'acme::button');
```

For more advanced use cases, instead of passing a view directly, you can provide a callback function:

```php
\Aero\AccountArea\AccountAreaSlot::inject('order.header.buttons', function ($data) {
    // add custom variables to the $data array

    return view('acme::button', $data);
});
```

<p class="callout info">These injections should typically sit inside the `boot` method of a Service Provider</p>

# Pages

# What are the default pages in the account area?

<table border="1" id="bkmrk-class-route-descript" style="border-collapse: collapse; width: 100%; height: 588.922px;"><colgroup><col style="width: 33.3731%;"></col><col style="width: 33.3731%;"></col><col style="width: 33.3731%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="height: 29.7969px;">**Class**  
</td><td style="height: 29.7969px;">**Route**  
</td><td style="height: 29.7969px;">**Description**  
</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">`AccountLoginPage`</td><td style="height: 29.7969px;">`login`</td><td style="height: 29.7969px;">A page where users can log in.</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">`AccountRegisterPage`</td><td style="height: 29.7969px;">`register`</td><td style="height: 29.7969px;">A page where guests can register.</td></tr><tr style="height: 46.5938px;"><td style="height: 46.5938px;">`AccountPasswordForgotPage`</td><td style="height: 46.5938px;">`password.forgot`</td><td style="height: 46.5938px;">A page where users can send a password reset email to their email.</td></tr><tr style="height: 46.5938px;"><td style="height: 46.5938px;">`AccountPasswordResetPage`</td><td style="height: 46.5938px;">`password.reset`</td><td style="height: 46.5938px;">A page where users can reset their password.</td></tr><tr style="height: 46.5938px;"><td style="height: 46.5938px;">`AccountOrdersPage`</td><td style="height: 46.5938px;">`account.orders`</td><td style="height: 46.5938px;">A page that lists all of a user's orders and lets them filter/search.</td></tr><tr style="height: 46.5938px;"><td style="height: 46.5938px;">`AccountOrderViewPage`</td><td style="height: 46.5938px;">`account.view-order`</td><td style="height: 46.5938px;">A page that shows more information about an order.</td></tr><tr style="height: 46.5938px;"><td style="height: 46.5938px;">`AccountAddressesPage`</td><td style="height: 46.5938px;">`account.addresses`</td><td style="height: 46.5938px;">A page that lists all of the users addresses.</td></tr><tr style="height: 46.5938px;"><td style="height: 46.5938px;">`AccountAddressNewPage`</td><td style="height: 46.5938px;">`account.new-address`</td><td style="height: 46.5938px;">A page where users can create a new address,</td></tr><tr style="height: 46.5938px;"><td style="height: 46.5938px;">`AccountAddressEditPage`</td><td style="height: 46.5938px;">`account.edit-address`</td><td style="height: 46.5938px;">A page where users can edit one of their addresses.</td></tr><tr style="height: 63.3906px;"><td style="height: 63.3906px;">`AccountDetailsPage`</td><td style="height: 63.3906px;">`account.details`</td><td style="height: 63.3906px;">A page where users can update their account details and change their password.</td></tr><tr style="height: 46.5938px;"><td style="height: 46.5938px;">`AccountInvoicePage`</td><td style="height: 46.5938px;">`account.view-invoice`</td><td style="height: 46.5938px;">A simple invoice for an order - currently not linked to from anywhere.</td></tr><tr style="height: 63.3906px;"><td style="height: 63.3906px;">`AccountOverviewPage`</td><td style="height: 63.3906px;">`account`</td><td style="height: 63.3906px;">The first page a user sees after they log in - currently redirects to the orders page.</td></tr></tbody></table>

<p class="callout info">The above classes reside in the `Aero\AccountArea\Http\Responses` namespace.</p>

# How do I create a custom page in the account area?

To create and register a custom account area page you need to use the `Aero\AccountArea\AccountArea::registerPage()` helper method.

This method expects you to pass a class that extends `Aero\AccountArea\AccountAreaPage`:

```php
\Aero\AccountArea\AccountArea\AccountArea::registerPage(\Aerocargo\Acme\CustomPage::class);
```

Your account area page class must implement the `title()`, `route()`, and `routeName()` methods that all should return a string.

It’s common practice to use [Laravel Localization](https://laravel.com/docs/6.x/localization) for the title and route so that they can change depending on the language used. You should not use this for the `routeName` as the `routeName` is used in code to refer to the route and therefore should never change.

You should also define a protected static steps and middleware array and a protected sections array:

- The static steps array can be used to define any extra response steps required for your page.
- The middleware array can be used to define any middleware required for your page (the most useful being ‘account’ which means users need to be logged in to view your page).
- The sections array defines the views that make up your page.

For example, here's how [`aerocargo/wishlists`](https://agora.aerocommerce.com/packages/aerocargo/wishlist) defines its page:

```php
class WishlistPage extends \Aero\AccountArea\AccountAreaPage
{
    use \Aero\AccountArea\Traits\HasAccountAreaLink;

    protected static $steps = [
        Steps\AttachWishlist::class,
    ];

    protected static $middleware = [
        'account',
    ];

    protected $sections = [
        'navbar' => 'account-area::sections.navbar',
        'page-header' => 'account-area::partials.page-header',
        'wishlist' => 'wishlist::account-area-wishlist',
    ];

    static function title(): string
    {
        return __('My Wishlist');
    }

    static function route(): string
    {
        return __('wishlist');
    }

    static function routeName(): string
    {
        return 'account.wishlist';
    }

    public static function toLink(): array
    {
        return [
            'icon' => 'wishlist::icons.heart',
            'text' => 'Your Wishlist',
        ];
    }
}
```

You can add your page to the navbar using the `addLink()` method:

```php
\Aero\AccountArea\AccountAreaPage::extend(function (\Aero\AccountArea\AccountAreaPage $page, \Closure $next) {
    $page->addLink(\Aerocargo\Wishlist\Http\Responses\WishlistPage::class);

    return $next($page);
});
```

<p class="callout info">For `addLink` to work, your page needs to use the `\Aero\AccountArea\Traits\HasAccountAreaLink` trait and implement the `toLink()` method (see the wishlist example above)</p>

# How do I add a section to an existing account area page?

You can use the `addSection()` method(s) to add a section to an existing form:

```php
\Aero\AccountArea\Http\Responses\AccountLoginPage::extend(function (\Aero\AccountArea\Http\Responses\AccountLoginPage $page, \Closure $next) {
    // Add it as the first section
    $page->addSection('acme', 'acme::section');

    // Add it after a specific section
    $page->addSectionAfter('acme', 'acme::custom', 'login-form');
  
    // Add it before a specific section
    $page->addSectionBefore('acme', 'acme::custom', 'login-form');
  
    return $next($page);
});
```

If you need to see the keys of the existing columns in order to position your new column appropriately, you can dump them out:

```php
\Aero\AccountArea\Http\Responses\AccountLoginPage::extend(function (\Aero\AccountArea\Http\Responses\AccountLoginPage $page, \Closure $next) {
    dd($page->getSections()->keys()->toArray());
  
    return $next($page);
});
```

# Sets

# What are the default sets in the account area?

<table border="1" id="bkmrk-class-method-route-a" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 33.3731%;"></col><col style="width: 33.3731%;"></col><col style="width: 33.3731%;"></col></colgroup><tbody><tr><td>**Class**  
</td><td>**Method**  
</td><td>**Route**  
</td></tr><tr><td>`AccountLoginSet`</td><td>Post</td><td>`login`</td></tr><tr><td>`AccountLogoutSet`</td><td>Post</td><td>`logout`</td></tr><tr><td>`AccountRegisterSet`</td><td>Post</td><td>`register`</td></tr><tr><td>`AccountPasswordForgotSet`</td><td>Post</td><td>`password.forgot`</td></tr><tr><td>`AccountPasswordResetSet`</td><td>Post</td><td>`password.reset`</td></tr><tr><td>`AccountAddressNewSet`</td><td>Post</td><td>`account.new-address`</td></tr><tr><td>`AccountAddressEditSet`</td><td>Put</td><td>`account.edit-address`</td></tr><tr><td>`AccountAddressMakeDefaultSet`</td><td>Put</td><td>`account.make-default-address`</td></tr><tr><td>`AccountDetailsSet`</td><td>Put</td><td>`account.details`</td></tr><tr><td>`AccountAddressDelete`</td><td>Delete</td><td>`account.delete-address`</td></tr></tbody></table>

<p class="callout info">The above classes reside in the `Aero\AccountArea\Http\Responses` namespace.</p>

# How do I create a custom set in the account area?

Sets are used for POST/PUT/DELETE requests.

To create and register a custom account area set you need to use on of the following methods:

- `Aero\AccountArea\AccountArea::registerPost()`
- `Aero\AccountArea\AccountArea::registerPut()`
- `Aero\AccountArea\AccountArea::registerDelete()`

These methods expects you to pass a class that extends `Aero\AccountArea\AccountAreaSet`.

```php
\Aero\AccountArea\AccountArea\AccountArea::registerDelete(\Aerocargo\Acme\CustomDelete::class);
```

Your account area set class must implement the `route()` and `routeName()` methods that all should return a string.

You should also define a protected static steps and middleware array:

- The steps array can be used to define any extra response steps required for your set.
- The middleware array can be used to define any middleware required for your set (the most useful being ‘account’ which means the user needs to be logged in).

For example, here's how [`aerocargo/wishlists`](https://agora.aerocommerce.com/packages/aerocargo/wishlist) defines its delete:

```php
class WishlistDelete extends \Aero\AccountArea\AccountAreaSet
{
    protected static $steps = [
        Steps\DeleteWishlist::class,
    ];

    protected static $middleware = [
        'account',
    ];

    static function route(): string
    {
        return __('wishlist');
    }

    static function routeName(): string
    {
        return 'account.wishlist';
    }
}
```

# Forms

# What are the default forms in the account area?

<table border="1" id="bkmrk-class-route-descript" style="border-collapse: collapse; width: 100%; height: 238.375px;"><colgroup><col style="width: 50.0596%;"></col><col style="width: 50.0596%;"></col></colgroup><tbody><tr style="height: 29.7969px;"><td style="height: 29.7969px;">**Class**  
</td><td style="height: 29.7969px;">**Description**  
</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">`AccountAddressEditForm`</td><td style="height: 29.7969px;">The edit address form.</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">`AccountAddressNewForm`</td><td style="height: 29.7969px;">The new address form.</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">`AccountDetailsForm`</td><td style="height: 29.7969px;">The account details form.</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">`AccountLoginForm`</td><td style="height: 29.7969px;">The login form.</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">`AccountPasswordForgotForm`</td><td style="height: 29.7969px;">The forgotten password form.</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">`AccountPasswordResetForm`</td><td style="height: 29.7969px;">The password reset form.</td></tr><tr style="height: 29.7969px;"><td style="height: 29.7969px;">`AccountRegisterForm`</td><td style="height: 29.7969px;">The register form.</td></tr></tbody></table>

<p class="callout info">The above classes reside in the `Aero\AccountArea\Http\Forms` namespace.</p>

# How do I create a custom form in the account area?

To create a form you need to create a class that extends the `\Aero\AccountArea\AccountAreaForm` class:

- The `$sections` array lists the views used to render the form.
- The `method()` method defines the method that the form will use (this should be `post`, `get`, `put`, or `delete`).
- The `route()` method should return the URL for the form. 
    - A `$data` variable is accessible in case the route requires parameters that are available in the data.

For example, here's how the login form is defined:

```php
class LoginForm extends \Aero\AccountArea\AccountAreaForm
{
    protected $sections = [
        'email' => 'account-area::partials.email-input',
        'password' => 'account-area::partials.password-input',
        'forgot-password' => 'account-area::partials.login-forgot-password-link',
        'submit' => 'account-area::partials.login-button',
    ];

    protected function method(): string
    {
        return 'post';
    }

    protected function route($data): string
    {
        return route('login');
    }
}
```

Don't forget to register your form:

```php
\Aero\AccountArea\AccountArea::registerForm(MyForm::class);
```