> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unleash-commerce.eu/llms.txt
> Use this file to discover all available pages before exploring further.

# Resources

> Replace and customize resources in Unleash Commerce Core

## Overview

Resources are Spatie Laravel Data resources used by core responses and controllers. Each resource has a contract in `Esign\UnleashCommerce\Core\Contracts\Resources`, and the core maps those contracts to default implementations via the `ResourceManifest`.

## Replace a core resource

Create a custom resource that implements the same contract. You can extend the core resource and override methods as needed:

```php theme={null}
namespace App\Http\Resources;

use Esign\UnleashCommerce\Core\Contracts\Resources\AlertResource as AlertResourceContract;
use Esign\UnleashCommerce\Core\Http\Resources\AlertResource as BaseAlertResource;
use Esign\UnleashCommerce\Core\Enums\AlertType;

class AlertResource extends BaseAlertResource implements AlertResourceContract
{
    public static function success(string $title, ?string $body = null): static
    {
        return new static(AlertType::SUCCESS, "Success: {$title}", $body);
    }
}
```

## Bind the resource in the manifest

Register your replacement in a service provider using the `ResourceManifest`:

```php theme={null}
<?php

namespace App\Providers;

use App\Http\Resources\AlertResource;
use Esign\UnleashCommerce\Core\Contracts\Resources\AlertResource as AlertResourceContract;
use Esign\UnleashCommerce\Core\Facades\ResourceManifest;
use Illuminate\Support\ServiceProvider;

class UnleashCommerceServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->registerResources();
    }

    protected function registerResources(): void
    {
        ResourceManifest::replace(
            AlertResourceContract::class,
            AlertResource::class
        );
    }
}
```

## Resolve the active resource class

When you need to nest resources or use them inside other resources, resolve the active implementation via `resourceClass()` so replacements are respected:

```php theme={null}
use Esign\UnleashCommerce\Core\Http\Resources\ProductResource;

$productData = ProductResource::resourceClass()::fromModel($product);
```

## Available core resources

See the [Resources Reference](../reference/resources) for a complete list of available resources you can replace.
