Appearance
Helpers
Overview
The dashboard ships with global helpers from:
src/helpers.phpapp/helpers.php- Toastify helper registration
This page lists the user-facing helpers that developers are likely to call directly.
setting(...)
Purpose:
- fetch one persisted setting or all settings
Signature:
php
setting(?string $key = null, mixed $default = null, bool $fresh = false): mixedParameters:
$key: setting key ornullfor all settings$default: fallback value$fresh: bypass cached value when true
Returns:
- a single setting value
- or an array of all settings when
$keyisnull
Example:
php
$name = setting('app_name');
$all = setting();app_name()
Purpose:
- resolve the localized application name
Signature:
php
app_name(): stringReturns:
- current-locale app name or
config('app.name')
Example:
php
$title = app_name();app_url()
Purpose:
- return the application base URL
Signature:
php
app_url(): stringExample:
php
$url = app_url();route_from_url(...)
Purpose:
- resolve a route name from a URL
Signature:
php
route_from_url(string $url): ?stringParameters:
$url: full or app-relative URL
Returns:
- matched route name
- or
nullwhen no route matches
Example:
php
$name = route_from_url(url('/en/dashboard/users'));route_allowed(...)
Purpose:
- check whether the current authenticated guard user can access a route-based permission
Signature:
php
route_allowed(string $route, string $guard = 'admins'): boolParameters:
$route: route name$guard: auth guard
Returns:
truewhen the route is allowedfalsewhen unauthenticated or denied
Example:
php
if (route_allowed('dashboard.users.edit')) {
// ...
}url_allowed(...)
Purpose:
- check whether a URL is allowed for the current authenticated guard user
Signature:
php
url_allowed(string $url, string $guard = 'admins'): boolParameters:
$url: URL to inspect$guard: auth guard
Returns:
truefor external URLs- otherwise the route-based permission result
Example:
php
if (url_allowed(route('dashboard.users.index'))) {
// ...
}throw_api_exception(...)
Purpose:
- normalize an exception into the standard Redot JSON error shape
Signature:
php
throw_api_exception(Throwable $e): JsonResponseParameters:
$e: any throwable
Returns:
- JSON response with
code,success,message, andpayload
Example:
php
return throw_api_exception($e);format_phone(...)
Purpose:
- convert a phone number into E.164 format
Signature:
php
format_phone(string $phone, string $country = 'EG'): stringParameters:
$phone: raw phone number$country: country code for parsing
Returns:
- formatted E.164 phone number
Example:
php
$value = format_phone('01000000000', 'EG');trigger_dependencies_build()
Purpose:
- invalidate generated frontend dependency output so the next request rebuilds it
Signature:
php
trigger_dependencies_build(): voidExample:
php
trigger_dependencies_build();hashed_asset(...)
Purpose:
- generate an asset URL with a version hash based on file mtime
Signature:
php
hashed_asset(string $path, ?bool $secure = null): stringParameters:
$path: public asset path$secure: force secure asset URL or let Laravel decide
Returns:
- asset URL with optional
?v=...hash
Example:
php
<link rel="stylesheet" href="{{ hashed_asset('assets/css/app.css') }}">collect_ellipsis(...)
Purpose:
- trim a collection-like value to a limit and append an ellipsis item
Signature:
php
collect_ellipsis($value = [], int $limit = 3, ?string $ellipsis = '...'): CollectionParameters:
$value: array-like input$limit: number of items to keep$ellipsis: text appended when items were omitted
Returns:
Collection
Example:
php
$tags = collect_ellipsis(['one', 'two', 'three', 'four'], 3);back_or_route(...)
Purpose:
- redirect back when the previous URL is internal and valid, otherwise return a named route URL
Signature:
php
back_or_route(string $route, mixed $parameters = [], bool $absolute = true): stringParameters:
$route: fallback route name$parameters: route parameters$absolute: whether to generate an absolute URL
Returns:
- previous app URL or fallback route URL
Example:
php
return redirect(back_or_route('dashboard.index'));switch_badge(...)
Purpose:
- render a yes/no badge as HTML
Signature:
php
switch_badge(mixed $value, ?string $true = null, ?string $false = null): stringParameters:
$value: truthy or falsy value$true: custom truthy label$false: custom falsy label
Returns:
- HTML string
Example:
php
{!! switch_badge($user->active) !!}component(...)
Purpose:
- render a component by name or class
Signature:
php
component(string $name, array $data = []): string|ViewParameters:
$name: component alias or class name$data: component data
Returns:
- rendered component view or
Viewinstance
Example:
php
$avatar = component('avatar', ['name' => $admin->name, 'image' => $admin->profile_picture]);search_model(...)
Purpose:
- apply a simple text search across columns and supported relations
Signature:
php
search_model(Builder|QueryBuilder $query, array $columns = [], ?string $term = null): Builder|QueryBuilderParameters:
$query: Eloquent or query builder$columns: columns to search$term: search term
Returns:
- modified builder
Example:
php
$query = search_model(User::query(), ['first_name', 'last_name', 'role.name'], request('q'));no_content()
Purpose:
- render a standard “No content” HTML fragment
Signature:
php
no_content(): stringReturns:
- HTML string
Example:
php
{!! $page->content ?: no_content() !!}is_image(...)
Purpose:
- determine whether a file path points to an image MIME type
Signature:
php
is_image(string $path): boolParameters:
$path: absolute or readable local file path
Returns:
truewhen MIME starts withimage/
Example:
php
if (is_image(public_path($path))) {
// ...
}static_page_url(...)
Purpose:
- generate a website static-page URL from a slug
Signature:
php
static_page_url(string $slug, array $parameters = [], bool $absolute = true): stringParameters:
$slug: static page slug$parameters: extra route parameters$absolute: whether to generate an absolute URL
Returns:
- website static page URL
Example:
php
$url = static_page_url('privacy-policy');current_admin()
Purpose:
- return the current authenticated admin from web or API guard
Signature:
php
current_admin(): ?AdminReturns:
- current admin model or
null
Example:
php
$admin = current_admin();current_user()
Purpose:
- return the current authenticated user from web or API guard
Signature:
php
current_user(): ?UserReturns:
- current user model or
null
Example:
php
$user = current_user();toastify()
Purpose:
- resolve the Toastify service instance
Signature:
php
toastify(): ToastifyReturns:
Redot\Toastify\Toastify
Example:
php
toastify()->success('Saved successfully');