The extension has a set of helpers that can make development a little easier for you.
admin_log('Title of action')
// OR
admin_log('Title of action', 'With details')
There are also certain types of helpers.
admin_log_warning('Title of warning action')
admin_log_primary(...)
admin_log_secondary(...)
admin_log_success(...)
admin_log_info(...)
admin_log_danger(...)
admin_log_dark(...)
admin_relative_path() // "/app/Admin"
// OR
admin_relative_path("with/my/path") // "/app/Admin/with/my/path"
admin_app_namespace() // "App\Admin"
// OR
admin_app_namespace("WithMyNamespace") // "App\Admin\WithMyNamespace"
admin_controller_model() // "Model/Class/Namespace"
admin_app_path() // "/Users/default/PhpstormProjects/project/app/Admin"
// OR
admin_app_path("MyPath") // "/Users/default/PhpstormProjects/project/app/Admin/MyPath"
admin_uri() // "/admin"
// OR
admin_uri("with/my/endpoint") // "/admin/with/my/endpoint"
admin_asset() // "https://domain.test/admin"
// OR
admin_asset("js/app.js") // "https://domain.test/admin/js/app.js"
admin_user()
// OR
admin_user()?->name
// OR
admin()
makeUrlWithParams(url()->current(), ["date" => now()->toDateString()])
// "https://domain.test?date=2022-01-01"
Even if the current link already has parameters, the helper will simply add new ones to the existing ones.
makeUrlWithParams("https://domain.test?user_id=1", ["date" => now()->toDateString()])
// "https://domain.test?user_id=1&date=2022-01-01"
urlWithGet("date" => now()->toDateString())
// "https://domain.test?date=2022-01-01"
Also, if you have or may have an unwanted parameter in the link, you can add its name to the exclusion list.
Suppose you have a user_id
parameter in your current link:
// https://domain.test?user_id=255
urlWithGet("date" => now()->toDateString(), ["user_id"])
// "https://domain.test?date=2022-01-01"