Skip to main content

Back-end Helpers

Import helpers from Qore\Next\System\Helpers.

Use helpers where they remove repeated framework plumbing. Keep domain-specific behaviour in services, resources or actions so it stays easy to test.

Framework

  • qore(): returns the Qore singleton. Use it for resource registration and services.
  • get_class_name($object): returns the short class name.
  • get_user_json_resource_class() and get_auth_user_json_resource_class(): read configured JSON resource classes.

URLs and auth

  • frontend_url($path, $params = [], $useDomain = true): builds a frontend URL using app.frontend_url and Qore's optional frontend prefix.
  • user(): returns the authenticated App\Models\User or throws AuthenticationException.
  • admin_user() and admin_role(): return the first user/role and cache the lookup for the request.
  • login($user) and logout($user = null): call the login/logout handlers configured on qore().

Formatting

  • to_string($value): converts scalars, enums, arrays, Arrayable, JsonSerializable and stringable objects to a readable string.
  • get_php_upload_limit(): returns the lower of upload_max_filesize and post_max_size in bytes.
  • bytes_presenter($bytes): formats bytes as B, KB, MB, GB or TB.
  • apply_timezone($date): parses a date if needed and applies config('app.timezone').