use Uccello\Core\Models\Module;
$module = ucmodule(1);
echo $module->name;
// => user
echo ucmodule('user')->name;
// => user
echo Module::where('name', 'user')->first()->name;
// => user
As Uccello cache the modules, please don't use ucmodule($moduleName) in your migration files. Your new created module could be not accessible with this helper.
Use Module::where('name', $moduleName)->first() instead.
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:
Translation overridden in app
Translation in package
Default translation overridden in app
Default translation in uccello
No translation
$personModule = ucmodule('person');
echo uctrans('field.first_name', $personModule);
// => First name (from resources/lang/en/person.php)
$userModule = ucmodule('user');
echo uctrans('block.general', $userModule); // This label is not translated in user module
// => General information (from vendor/uccello/uccello/resources/lang/en/default.php)
echo trans('uccello::default.block.general');
// => General information
ucroute()
Retrieves a route and automatically adds domain and module params.
The domain param is only added if the multi domains option is enabled.
use Uccello\Core\Models\Uitype;
echo uitype(1)->name;
// => text
echo uitype('text')->name;
// => text
echo Uitype::where('name', 'text')->name;
// => text
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.
$user = auth()->user();
// The ACME domain is a child of Uccello domain.
$acmeUser = \App\User::where('domain_id', ucdomain('acme'))->first();
echo ucattribute($user, 'domain.name');
// => Uccello
echo ucattribute($user, 'domain.parent.name');
// => null
echo ucattribute($acmeUser, 'domain.parent.name');
// => Uccello
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.
ucnotify('My message'); // Displays a black info toast
ucnotify('Info message', 'info'); // Displays a black info toast
ucnotify('Success message', 'success'); // Displays a green success toast
ucnotify('Warning message', 'warning'); // Displays an orange warning toast
ucnotify('Error message', 'error'); // Displays a red error toast
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.
// Retrieve by uuid
$record = ucrecord('00013d27-1195-4bcc-b05d-ee63e2aaa471');
// Retrieve by id and model class
$record = ucrecord(1, \App\User::class);