Helpers

Definition

A helper is a php function you can use in all your application, in both controllers and views.

Default helpers

ucdomain()

Retrieves a domain by id or slug.

use Uccello\Core\Models\Domain;

$domain = ucdomain(1);
echo $domain->name;
// => Uccello

echo ucdomain('uccello')->name;
// => Uccello

echo Domain::where('slug', 'uccello')->first()->name;
// => Uccello

ucmodule()

Retrieves a module by id or name.

uctrans()

Retrieves the complete prefix of a label and translated it. If the translation does not exist, it tries to find a default one according to priorities. If no translation exist, it displays only the label without translation.

Priority:

  1. Translation overridden in app

  2. Translation in package

  3. Default translation overridden in app

  4. Default translation in uccello

  5. No translation

ucroute()

Retrieves a route and automatically adds domain and module params.

The domain param is only added if the multi domains option is enabled.

uclog()

Displays log data into Laravel Debug Bar.

uitype()

Retrieves an uitype by id or name.

displaytype()

Retrieves a display type by id or name.

capability()

Retrieves a capability by id or name.

ucasset()

Returns the complete path of an asset available in an external package.

ucattribute()

Returns a record attribute value. It is able to follow a complex path according to models definition (e.g. 'domain.parent.name'). If the attribute is not accessible, it returns null.

To be able to use this helper, you have to define the belongsTo relations in the different models.

ucnotify()

Displays a flash info toast containing the message of your choice.

ucrecord()

Retrieves a record by id or uuid. If you want to retrieves a record by its id, you have to specify its model class two.

All records have an uuid defined in the database table called by default uccello_entities.

Last updated

Was this helpful?