›
›
›
  1. docs
  2. ›
  3. byrcsc/laravel-whitelabel
1.x
Browse documentationOpenClose

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Brand definitions
  • Fallback and clearing
  • Brand resolution
  • Brand repositories

Using brands

  • Blade components
  • Mail and notifications
  • Queues
  • Spatie Multitenancy

Operations

  • Manage database brands
  • Custom drivers and resolvers
  • Events and listeners
  • Cache management

Reference

  • Configuration
  • Public API
  • Console commands
  • Testing
  • Troubleshooting

Getting started

  • Introduction
  • Installation and setup
  • Quick start

Core concepts

  • Brand definitions
  • Fallback and clearing
  • Brand resolution
  • Brand repositories

Using brands

  • Blade components
  • Mail and notifications
  • Queues
  • Spatie Multitenancy

Operations

  • Manage database brands
  • Custom drivers and resolvers
  • Events and listeners
  • Cache management

Reference

  • Configuration
  • Public API
  • Console commands
  • Testing
  • Troubleshooting

byrcsc/laravel-whitelabel · 1.x

Brand definitions.

Define the fixed brand fields and application-specific settings accepted by every driver.

A brand definition contains the values that belong to one brand. You use the same fields whether you configure a brand in a file, store it in the database, or create it while the application is running.

use Byrcsc\Whitelabel\Brand;

$brand = new Brand('acme', [
    'name' => 'Acme',
    'domain' => 'app.acme.com',
    'logo' => ['disk' => 'public', 'path' => 'brands/acme/logo.svg'],
    'favicon' => 'https://cdn.acme.com/favicon.svg',
    'colors' => ['primary' => '#7c3aed'],
    'mail' => [
        'from_name' => 'Acme Support',
        'from_address' => 'hello@acme.com',
    ],
    'settings' => ['support_url' => 'https://support.acme.com'],
]);

Fixed fields

KeyAccepted valueResult
namestringDisplay name
domainbare host stringHost used by the domain resolver
logostring or asset mapLogo asset
faviconstring or asset mapFavicon asset
colorsmap of string names to string valuesCSS and mail colours
mailsender mapOptional from_name and from_address
settingsnamed array of scalar or nested array valuesApplication-specific data

The domain is normalized to lowercase and cannot contain a scheme or path. mail.from_address must be an email address unless it is an empty string.

Asset values

A string can be a path on whitelabel.assets.disk:

'logo' => 'brands/acme/logo.svg',

It can also be an absolute or protocol-relative URL, which passes through without Storage handling:

'logo' => 'https://cdn.acme.com/logo.svg',

Use a map to choose a disk:

'logo' => ['disk' => 's3', 'path' => 'brands/acme/logo.svg'],

The package calls Storage::disk($disk)->url($path). It does not call exists() and does not verify that the URL is public.

Application settings

Settings accept booleans, floats, integers, strings, and nested arrays. The top level must use named keys:

'settings' => [
    'features' => ['reports' => true],
    'support' => ['email' => 'support@acme.com'],
    'tags' => ['enterprise', 'annual'],
],

Read them through Brand::setting() or the helper:

$reports = brand('settings.features.reports', false);
$support = brand()?->setting('support.email');

An asset-shaped setting is available through assetUrl():

'settings' => [
    'og_image' => ['disk' => 's3', 'path' => 'brands/acme/card.png'],
],
$url = brand()?->assetUrl('og_image');

Validation rules

Unknown top-level keys and unknown mail or asset keys throw InvalidBrandDefinition. Null is invalid at every depth. Remove a key to inherit it or use an empty value to clear it.

Objects and resources are not accepted in settings. Colour names and values must be strings, and a colour name cannot be empty.

BrandDefinition::validate(string $brandId, array $definition): array exposes the same validation and normalization used by both included drivers.

What to read next

  • Fallback and clearing to distinguish an omitted key from an empty value.
  • Public API for every Brand accessor and return type.
  • Troubleshooting for definition validation failures.
PreviousQuick startNextFallback and clearing
View source

On this page

  1. Fixed fields
  2. Asset values
  3. Application settings
  4. Validation rules
  5. What to read next