Р
Size: a a a
Р
Р
М
М
f
A
Categories::extendFormFields(function($form, $model, $context)
{
if (!$model instanceof MyModel) {
return;
}
$form->addFields([
'my_field' => [
'label' => 'My Field',
'comment' => 'This is a custom field I have added.',
],
]);
});
A
М
М
class Plugin extends PluginBase
{
[...]
public function boot()
{
// Local event hook that affects all users
User::extend(function($model) {
$model->bindEvent('model.getAttribute', function($attribute, $value) {
if ($attribute == 'foo') {
return 'bar';
}
});
});
// Double event hook that affects user #2 only
User::extend(function($model) {
$model->bindEvent('model.afterFetch', function() use ($model) {
if ($model->id != 2) {
return;
}
$model->bindEvent('model.getAttribute', function($attribute, $value) {
if ($attribute == 'foo') {
return 'bar';
}
});
});
});
}
}
f
М
f
М
A
A
f
М