›
byrcsc/laravel-whitelabel · 1.x
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'],
]);| Key | Accepted value | Result |
|---|---|---|
name | string | Display name |
domain | bare host string | Host used by the domain resolver |
logo | string or asset map | Logo asset |
favicon | string or asset map | Favicon asset |
colors | map of string names to string values | CSS and mail colours |
mail | sender map | Optional from_name and from_address |
settings | named array of scalar or nested array values | Application-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.
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.
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');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.
Brand accessor and return type.