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 the Aero\AccountArea\AccountArea::registerPost(), Aero\AccountArea\AccountArea::registerPut(), or Aero\AccountArea\AccountArea::registerDelete(), helper method. This method expects you to pass a class that extends Aero\AccountArea\AccountAreaSet.

<?php

namespace Acme\MyModule;

use Acme\MyModule\AccountArea\Pages\CustomSet;
use Aero\AccountArea\AccountArea;
use Aero\Common\Providers\ModuleServiceProvider;

class ServiceProvider extends ModuleServiceProvider
{
   public function setup()
   {
       AccountArea::registerPost(CustomSet::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).

<?php

namespace Acme\MyModule\AccountArea\Pages;

use Aero\AccountArea\AccountAreaSet;

class CustomSet extends AccountAreaSet
{
   protected static $steps = [
       Steps\DeleteWishlist::class,
   ];

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

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

   static function routeName(): string
   {
       return 'acme.my-module.wishlist.delete';
   }
}

Articles in this section

Was this article helpful?
0 out of 0 found this helpful