Global helpers

admin()

Returns the logged administrator or null.
Permission checks are described in Permissions.

autoAjax()

Returns a JSON response builder for messages, errors and store data.
See the bootstrap request for a larger example.

Frontend editor

uploadable(), linkable() and encryptText(): available with the crudadmin/website package (composer require crudadmin/website).
With the frontend editor enabled, administrators can replace images and links rendered by these helpers directly on the website. Without the editor, the default values are returned.

Other helpers

Translation helpers (_(), localeUrl(), switchLocale(), localizedRoutes()) are described in Localization.

Text obfuscation

encryptText($text) obfuscates e-mails or phone numbers as base64 for frontend decoding. It is not encryption and should not be used to protect secrets.

Admin facade

Request type

Admin::isAdmin() is true for URLs starting with /admin. Admin::isFrontend() is true for other HTTP requests, never in console.

Models

Request cache

A cache living for one request, shared by the whole administration.

Log

Configuration switches are available as Admin::isEnabledLocalization(), Admin::isEnabledAdminLocalization(), Admin::isHistoryEnabled() and Admin::isRolesEnabled(), see Configuration.

Admin events

Migration events

fire_after_migration runs after the table was migrated, fire_after_all after all tables. The _noScheme suffix runs the callback without the schema builder. Callbacks run once. For hooks inside the model see migration hooks.

Generator events

admin:model fires admin.command.model.create.stub_path, stub, namespaces, parameters, fields and options. admin:module fires admin.command.module.create.stub_path, stub and options. Arguments are passed by reference.

Extending from packages

Registering models

A model whose class basename is already registered is skipped.

Merging package config

Extend Admin\Providers\AdminHelperServiceProvider and merge your defaults. Values from the application config/admin.php always win, lists are appended, and package scripts are loaded before application scripts.