How do I add settings to the product model?

Using the same syntax as when you create settings

<?php

namespace Acme\MyModule;

use Aero\Catalog\Models\Product;
use Aero\Common\Providers\ModuleServiceProvider;
use Aero\Common\Settings\SettingGroup;

class ServiceProvider extends ModuleServiceProvider
{
   public function setup()
   {
       Product::settings('my-module', function (SettingGroup $group) {
           $group->encrypted('password');
           $group->boolean('require_password_to_view')->default(false);
       });
   }
}

To access your settings value you need to use the settings method on the product model, passing in the key for the setting you want.

<?php

namespace Acme\MyModule;

use Aero\Catalog\Models\Product;
use Aero\Common\Providers\ModuleServiceProvider;
use Aero\Common\Settings\SettingGroup;

class ServiceProvider extends ModuleServiceProvider
{
   public function setup()
   {
       Product::settings('my-module', function (SettingGroup $group) {
           $group->encrypted('password');
           $group->boolean('require_password_to_view')->default(false);
       });

       $product = Product::first();

       $password = $product->settings('my-module.password');

       dd($password);
   }
}

Revision #2
Created 2026-09-02 13:29:11 UTC by Michael Price
Updated 2026-09-02 13:37:03 UTC by Michael Price