›
byrcsc/laravel-whitelabel · 1.x
Reference the supported classes, contracts, methods, events, exceptions, and publish tags.
Use this page when calling Laravel Whitelabel 1.x from your application or an extension. The classes and methods below form the package's public API.
The facade is Byrcsc\Whitelabel\Facades\Whitelabel.
current(): ?Brand
isResolved(): bool
activate(Brand|string $brand): Brand
forget(): void
flush(): void
define(string $id, array $definition = []): Brand
find(string $id): ?Brand
findByDomain(string $domain): ?Brand
overridden(): ?BrandThe global helper has this effective signature:
brand(?string $key = null, mixed $default = null): mixedWith no key it returns Brand|null. With a key it reads the active brand by
dot notation or returns the supplied default.
BrandConstructor:
new Brand(
public readonly string $id,
array $definition,
?Brand $fallback = null,
)Accessors:
get(string $key, mixed $default = null): mixed
has(string $key): bool
id(): string
name(): ?string
domain(): ?string
logo(): ?BrandAsset
favicon(): ?BrandAsset
asset(string $key): ?BrandAsset
logoUrl(): ?string
faviconUrl(): ?string
assetUrl(string $key): ?string
colors(): array
color(string $name, ?string $default = null): ?string
mailFromName(): ?string
mailFromAddress(): ?string
settings(): array
setting(string $key, mixed $default = null): mixed
definition(): array
fallback(): ?Brand
withFallback(?Brand $fallback): Brand
toArray(): arrayBrand is immutable and implements Laravel's Arrayable contract.
BrandAsset and BrandDefinitionnew BrandAsset(public string $path, public ?string $disk = null)
BrandAsset::fromDefinition(string|array $value): ?BrandAsset
$asset->isAbsoluteUrl(): bool
$asset->url(): string
$asset->toArray(): arrayBrandDefinition::validate(string $brandId, array $definition): array
BrandDefinition::inherit(array $base, array $own): arrayBrandDefinition exposes constants NAME, DOMAIN, LOGO, FAVICON,
COLORS, MAIL, MAIL_FROM_NAME, MAIL_FROM_ADDRESS, SETTINGS, KEYS, and
NON_INHERITED.
Byrcsc\Whitelabel\Contracts\BrandRepository defines:
all(): array
find(string $id): ?Brand
findByDomain(string $domain): ?Brand
has(string $id): bool
create(string $id, array $definition): Brand
update(string $id, array $definition): Brand
delete(string $id): bool
flush(): voidThe included implementations are ConfigBrandRepository,
DatabaseBrandRepository, and CachedBrandRepository. The cache decorator adds:
inner(): BrandRepositoryBrandRepositoryManager supports Laravel Manager methods driver() and
extend(), plus:
getDefaultDriver(): stringConfigBrandRepository::NAME is config and
DatabaseBrandRepository::NAME is database.
interface BrandResolver
{
public function resolve(): ?Brand;
}
interface ProvidesBrand
{
public function brand(): ?Brand;
}The included resolvers are OverrideResolver, TenantResolver,
DomainResolver, and DefaultResolver.
When Spatie Multitenancy is installed, SwitchTenantBrandTask implements:
makeCurrent(IsTenant $tenant): void
forgetCurrent(): voidThe optional EagerResolveBrand middleware exposes Laravel's standard
handle(Request $request, Closure $next): Response method.
Add the marker trait Byrcsc\Whitelabel\Queue\BrandAware to a queued class.
The public Markdown helper methods are:
BrandedMarkdown::logoUrl(): ?string
BrandedMarkdown::name(): string
BrandedMarkdown::headingStyle(): string
BrandedMarkdown::buttonStyle(string $color): stringStyles, Logo, and Favicon expose render(): View and
shouldRender(): bool. Prefer their Blade tags over constructing them.
Styles::DEFAULT_PREFIX is brand.
InteractsWithBrands provides protected test helpers:
actingWithBrand(array|string $brand, string $id = 'testing'): Brand
defineBrand(string $id, array $definition = []): BrandBrandRecord::factory() returns the public BrandRecordFactory, which exposes:
definition(): array
bare(): static
identifiedBy(string $identifier): staticThese events each accept and expose public readonly Brand $brand:
BrandActivatedBrandDeactivatedBrandCreatedBrandUpdatedBrandDeletedEvery package exception implements
Byrcsc\Whitelabel\Exceptions\WhitelabelException:
| Exception | Condition |
|---|---|
InvalidBrandDefinition | A definition has an unknown, null, malformed, or incorrectly typed value |
UnknownBrand | Activation or update names an absent brand, or config lacks its default |
UnsupportedBrandOperation | A write is attempted through the config driver |
BrandAlreadyExists | A database identifier or domain collides |
CapturedBrandMissing | A queued class cannot restore its captured brand |
The interface extends Throwable, so one catch handles package failures:
use Byrcsc\Whitelabel\Exceptions\WhitelabelException;
try {
Whitelabel::activate($brandId);
} catch (WhitelabelException $exception) {
report($exception);
}Byrcsc\Whitelabel\WhitelabelServiceProvider is the package service provider.
The command classes are Commands\InstallCommand for whitelabel:install and
Commands\ClearBrandCacheCommand for whitelabel:clear. Publish tags are
whitelabel-config, whitelabel-migrations, and whitelabel-views.
BrandRecord remains an internal persistence model even though its factory is
public for tests. The repository never returns it.