Extending the Platform

The Preads Platform features a highly modular architecture that allows developers to extend core functionality without modifying framework files. This is achieved through an isolated Addon System and a specialized Service discovery engine.


🏗️ Modular Philosophy

All custom features should be developed as Addons. This ensures:

  1. Upgradability: Core platform updates will not overwrite your custom code.
  2. Isolation: Bugs in an addon are contained and can be disabled instantly.
  3. Portability: Addons can be moved between different Preads installations.

🧩 Building an Addon

1. Directory Structure

Addons reside in the root /addons directory using the HansalDev namespace.

/addons/MyCustomAddon/
├── addon.json              # The manifest (Required)
├── MyServiceProvider.php   # Service registration (Required)
├── App/                    # Business Logic (Controllers, Models)
├── Database/
│   └── Migrations/         # Custom tables
├── resources/
│   └── views/              # Blade templates
└── routes/
    └── web.php             # Addon-specific routes

2. The Manifest (addon.json)

The manifest defines the addon's identity and how it hooks into the platform UI.

Property Type Description
name string Unique technical identifier.
display_name string Human-readable name shown in Admin panel.
provider string Fully qualified class name of the Service Provider.
enabled bool Current status of the addon.
menus object Navigation links for admin or publisher areas.
widgets object Dashboard cards for analytics.

3. Service Provider

Your Service Provider is the bridge between the addon and the Laravel framework.

namespace HansalDev\MyCustomAddon;

use Illuminate\Support\ServiceProvider;

class MyServiceProvider extends ServiceProvider
{
    public function boot()
    {
        // Load Addon Routes
        $this->loadRoutesFrom(__DIR__.'/routes/web.php');

        // Load Views with a namespace (e.g., myaddon::index)
        $this->loadViewsFrom(__DIR__.'/resources/views', 'myaddon');

        // Load Database Migrations
        $this->loadMigrationsFrom(__DIR__.'/Database/Migrations');
    }
}

⚓ Platform Hooks

Dashboard Widgets

You can inject custom analytics cards into the Admin or Publisher dashboards via the widgets key in addon.json.

"widgets": {
    "admin": [
        {
            "name": "addon_revenue_chart",
            "view": "myaddon::admin.widgets.revenue",
            "order": 10,
            "size": "col-md-6"
        }
    ]
}

Global Helpers

The platform provides a helper to check for addon status, allowing for conditional logic in core templates or other addons.

if (addon_active('CpvSystem')) {
    // Logic for when the Video addon is enabled
}

🎨 Theme Extensions

The platform's frontend is powered by a Section Engine. Developers can create new UI sections by adding Blade files to the resources/views/sections directory. These sections automatically become available in the Admin's Visual Section Editor.


Back to Developer Guide