public function boot() { User::extend(function ($model) { $model->hasOne['forum_member'] = ['RainLab\\Forum\\Models\\Member']; $model->bindEvent('model.beforeDelete', function () use($model) { $model->forum_member && $model->forum_member->delete(); }); }); UsersController::extendFormFields(function ($widget, $model, $context) { // Prevent extending of related form instead of the intended User form if (!$widget->model instanceof \RainLab\User\Models\User) { return; } if ($context != 'update') { return; } if (!Member::getFromUser($model)) { return; } $widget->addFields(['forum_member[username]' => ['label' => 'rainlab.forum::lang.settings.username', 'tab' => 'Forum', 'comment' => 'rainlab.forum::lang.settings.username_comment'], 'forum_member[is_moderator]' => ['label' => 'rainlab.forum::lang.settings.moderator', 'type' => 'checkbox', 'tab' => 'Forum', 'span' => 'auto', 'comment' => 'rainlab.forum::lang.settings.moderator_comment'], 'forum_member[is_banned]' => ['label' => 'rainlab.forum::lang.settings.banned', 'type' => 'checkbox', 'tab' => 'Forum', 'span' => 'auto', 'comment' => 'rainlab.forum::lang.settings.banned_comment']], 'primary'); }); UsersController::extendListColumns(function ($widget, $model) { if (!$model instanceof \RainLab\User\Models\User) { return; } $widget->addColumns(['forum_member_username' => ['label' => 'rainlab.forum::lang.settings.forum_username', 'relation' => 'forum_member', 'select' => 'username', 'searchable' => false]]); }); }
public function boot() { // Alias $alias = AliasLoader::getInstance(); $alias->alias('Carbon', '\\Carbon\\Carbon'); // $alias->alias('DB', '\Barryvdh\Debugbar\Facade'); $alias->alias('CW', '\\Clockwork\\Support\\Laravel\\Facade'); // User model extend UserModel::extend(function ($model) { $model->addFillable(['phone', 'patronymic']); $model->hasOne['profile'] = ['Abnmt\\MRC\\Models\\Profile']; $model->hasMany['orders'] = ['Abnmt\\MRC\\Models\\Order']; $model->hasMany['userevents'] = ['Abnmt\\MRC\\Models\\UserEvent']; $model->hasManyThrough['courses'] = ['Abnmt\\MRC\\Models\\Event', 'through' => 'Abnmt\\MRC\\Models\\UserEvent']; $model->hasManyThrough['events'] = ['Abnmt\\MRC\\Models\\Event', 'through' => 'Abnmt\\MRC\\Models\\UserEvent']; }); // User controller extend Form UsersController::extendFormFields(function ($widget) { // $configFile = __DIR__ . '/config/profile_fields.yaml'; // $config = Yaml::parse(File::get($configFile)); $config = ['phone' => ['label' => 'Телефон', 'span' => 'auto'], 'patronymic' => ['label' => 'Отчество', 'span' => 'auto']]; $widget->addFields($config); }); // User controller extend List UsersController::extendListColumns(function ($list, $model) { if (!$model instanceof UserModel) { return; } $config = ['surname' => ['label' => 'Фамилия'], 'patronymic' => ['label' => 'Отчество'], 'phone' => ['label' => 'Телефон']]; $list->addColumns($config); }); }
public function boot() { User::extend(function ($model) { $model->hasOne['forum_member'] = ['RainLab\\Forum\\Models\\Member']; }); UsersController::extendFormFields(function ($widget, $model, $context) { if ($context != 'update') { return; } if (!Member::getFromUser($model)) { return; } $widget->addFields(['forum_member[username]' => ['label' => 'Username', 'tab' => 'Forum', 'comment' => 'The display to represent this user on the forum.'], 'forum_member[is_moderator]' => ['label' => 'Forum moderator', 'type' => 'checkbox', 'tab' => 'Forum', 'span' => 'auto', 'comment' => 'Place a tick in this box if this user can moderate the entire forum.'], 'forum_member[is_banned]' => ['label' => 'Banned from forum', 'type' => 'checkbox', 'tab' => 'Forum', 'span' => 'auto', 'comment' => 'Place a tick in this box if this user is banned from posting to the forum.']], 'primary'); }); UsersController::extendListColumns(function ($widget, $model) { if (!$model instanceof \RainLab\User\Models\User) { return; } $widget->addColumns(['forum_member_username' => ['label' => 'Forum Username', 'relation' => 'forum_member', 'select' => '@username', 'searchable' => true]]); }); }