›
›
›
  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

Quick start.

Configure two host-based brands and render their identity in a shared layout.

Laravel Whitelabel can load brands from configuration or the database. This tutorial uses the config driver because it is the shortest path to rendering two brands. Use the database driver when customers create or edit their branding at runtime; the rendering and resolution code stays the same.

The tutorial makes one Laravel route render a different name, logo, favicon, and colour for two hosts using the default domain resolver.

1. Add two brands

Edit config/whitelabel.php:

'default' => 'default',

'brands' => [
    'default' => [
        'name' => 'Example',
        'logo' => ['disk' => 'public', 'path' => 'brands/default/logo.svg'],
        'favicon' => ['disk' => 'public', 'path' => 'brands/default/favicon.svg'],
        'colors' => ['primary' => '#111827'],
    ],

    'acme' => [
        'name' => 'Acme',
        'domain' => 'acme.test',
        'logo' => ['disk' => 'public', 'path' => 'brands/acme/logo.svg'],
        'colors' => ['primary' => '#7c3aed'],
    ],
],

acme omits its favicon, so it inherits the default favicon. Domains never inherit because one host must identify no more than one brand.

2. Put the assets on the public disk

Store these files on the disk named by each definition:

storage/app/public/brands/default/logo.svg
storage/app/public/brands/default/favicon.svg
storage/app/public/brands/acme/logo.svg

If the public disk is not linked yet, create its link:

php artisan storage:link

The package builds asset URLs. It does not upload these files or check whether they exist.

3. Render the brand in a layout

Add the components and helper to a Blade layout:

<!doctype html>
<html lang="en">
<head>
    <x-whitelabel::favicon />
    <x-whitelabel::styles />
</head>
<body>
    <header>
        <x-whitelabel::logo class="h-8" />
        <span>{{ brand('name') }}</span>
    </header>

    <main style="color: var(--brand-primary)">
        {{ $slot }}
    </main>
</body>
</html>

The first call to a helper or component resolves the brand. A request for acme.test selects acme. An unclaimed host reaches the final default resolver and selects default.

4. Read application settings

Add an application-specific value to a definition:

'settings' => [
    'support_url' => 'https://support.acme.test',
],

Read it with dot notation:

<a href="{{ brand('settings.support_url') }}">Support</a>

Pass a default for a setting that may not exist:

{{ brand('settings.tagline', 'Welcome') }}

5. Verify both hosts

Point acme.test at your local application and open it. The page uses Acme's name, logo, and primary colour with the default favicon. Open the same route on an unclaimed local host to see the default brand.

What to read next

  • Fallback and clearing to control which default values a brand inherits.
  • Blade components for component attributes and empty states.
  • Mail and notifications to apply the same brand to outgoing mail.
PreviousInstallation and setupNextBrand definitions
View source

On this page

  1. 1. Add two brands
  2. 2. Put the assets on the public disk
  3. 3. Render the brand in a layout
  4. 4. Read application settings
  5. 5. Verify both hosts
  6. What to read next