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.
\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 defines its delete:
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';
}
}