Functions available everywhere: in controllers, Blade views and your plugin. Most live in app/Helpers/Helper.php; setting() comes with the settings store. The ones you will actually use are below; the rest of the file holds small legacy utilities.
| Function | Behaviour |
|---|---|
setting(string $key, mixed $default = null): mixed | Read a database setting. Settings are loaded once per request, so repeated calls are cheap |
setting(array $values) | Set several values (call setting()->save() afterwards) |
setting() | The settings store itself: ->set(), ->forget(), ->save() |
On an installation that has not finished the installer the settings table may not exist yet; core code checks config('dotartisan.installed') before reading settings during boot. See Settings screens.
| Function | Behaviour |
|---|---|
theme_option(string $key, mixed $default = null): mixed | Value for the active front theme: saved value, then the theme.json default, then $default |
set_theme_option(string $key, mixed $value = null): void | Override an option for the current request only; nothing is saved |
override_theme_options(array|object $settings): void | Apply many overrides at once, skipping empty values. Pages pass their settings JSON through it |
theme_nested_option(string $key, ?string $default = null, string $theme = 'light'): ?string | Read a key inside a nested option array |
google_fonts_list(int|false $index = false): array | The font catalogue used by font fields |
| Function | Behaviour |
|---|---|
menu($idOrName, $type = null, array $options = []): mixed | Render a menu (by id or name) with one of the theme's templates in menu/: bootstrap, megamenu, mobile, footer, topbar, list, inline. '_json' returns the item tree instead of HTML. The tree is cached for 15 minutes and cleared when the menu changes |
menuIcon(MenuItem $item): mixed | The HTML for a menu item's icon (inline SVG, image or icon class) |
clean_page_builder(mixed $html): mixed | Strip the <body> wrapper from page-builder output before saving |
sanitize_html(mixed $html): mixed | strip_tags() keeping only strong, a, p, div, span. It does not remove attributes, so it is not an XSS filter for untrusted input |
record_page_visit($model): bool | Count a view of a model that tracks views, with the cooldown from the cooldown_expires_hours setting |
getPageType(Page $page) | The AppPages definition a page serves (AppPages::firstForPage()) |
bsColumns(int $columns = 3) | Bootstrap row-columns classes for a responsive grid (row-cols-md-3 row-cols-sm-2 row-cols-1) |
pluginView($view, $params) | Render alias::view, preferring a copy in views/plugins/{alias}/ when one exists |
setActive(string $path): string | Returns ' active' when the current path starts with $path |
| Function | Behaviour |
|---|---|
fileUpload(UploadedFile $input, ?string $path = null): string|false | Store an upload on the public files disk (PUBLIC_FILES_DISK) under $path (default {month}/{day}) and return its URL. It keeps the client's original file name, so a second upload with the same name replaces the first: validate type and size, and prefer the media library for anything user-facing |
tempFileUpload(UploadedFile $input, bool $public = false, bool $onlyUrl = false, ?string $dir = null) | Store in the temporary area with a generated name; returns details (disk, path, url, size…) or just the URL. php artisan dotartisan:clean-temp removes old files |
generateFileUrl($path, $disk) | Storage::disk($disk)->url($path) |
sanitize_filename($name, bool $allow_extension = true): string, slugify_name($name, bool $timestamp = true) | Safe file names |
| Function | Behaviour |
|---|---|
__e(?string $key, array $params = []): string | Translate, or return an empty string when the key is empty |
format_number(int $number): string | Short form: 1200 → 1.2K, 3 000 000 → 3M |
get_initials(string $name): string | Up to two initials (Ada Lovelace → A L) |
available_currencies(): array | ISO 4217 code → currency name |
timezones_list(): array | Timezone choices for selects |
job_cache_time($hours = null) | A timestamp $hours ahead (default config('dotartisan.cache_time')) |
Modules can ship their own global functions through autoload.files in their composer.json. TruCommerce does (Modules/TruCommerce/trucommerce.php), for example trucommerce_money($amount, $currency) for formatted prices and trucommerce_order_statuses(). Prefix your own functions with your alias and wrap each in if (! function_exists(...)).
module_path('Name', 'relative/path') — absolute path inside a module.theme_url('/themes/echo/images/x.png') — URL of a theme asset.views($model) — the view counter behind record_page_visit().