Inheritance: extends Backend\Classes\Controller
示例#1
0
 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]]);
     });
 }
示例#2
0
 public function boot()
 {
     UserModel::extend(function ($model) {
         $model->hasOne['profile'] = ['KurtJensen\\Profile\\Models\\Profile', 'key' => 'user_id', 'otherKey' => 'id'];
     });
     UsersController::extendFormFields(function ($form, $model, $context) {
         if (!$model instanceof UserModel) {
             return;
         }
         if (!$model->exists) {
             return;
         }
         if ($form->getContext() != 'update') {
             return;
         }
         if (!ProfileModel::getFromUser($form->model)) {
             return;
         }
         // Flash::success($model->profile->created_at);
         // Ensure that a profile model always exists
         ProfileModel::getFromUser($model);
         $groupsField = $form->getField('groups');
         $form->removeField('groups');
         $form->addTabFields(['primary_usergroup' => ['label' => 'Primary User Group', 'comment' => 'Set the primary group association for this user.', 'tab' => 'rainlab.user::lang.user.account', 'type' => 'dropdown', 'options' => $this->getPrimaryUsergroupOptions()], 'groups' => ['label' => 'Groups/Roles', 'tab' => 'rainlab.user::lang.user.account', 'type' => 'relation', 'emptyOption' => 'There are no user groups available.'], 'profile[per_text_1]' => ['label' => Settings::get('per_label_1', 'Place of Birth'), 'comment' => Settings::get('per_desc_1', 'The town you were born in.'), 'tab' => 'Personal', 'type' => Settings::get('per_typ_1', 'text'), 'options' => ['test' => 'test', 'test2' => 'test2', 'custom' => 'custom']], 'profile[per_text_2]' => ['label' => Settings::get('per_label_2', 'Favorite Activity'), 'comment' => Settings::get('per_desc_2', 'The thing you like to do most.'), 'tab' => 'Personal', 'type' => Settings::get('per_typ_2', 'text')], 'profile[per_text_3]' => ['label' => Settings::get('per_label_3', 'About Me'), 'comment' => Settings::get('per_desc_3', 'All about you.'), 'tab' => 'Personal', 'type' => Settings::get('per_typ_3', 'textarea')], 'profile[per_text_4]' => ['label' => Settings::get('per_label_4', 'Hobbies'), 'comment' => Settings::get('per_desc_4', 'How you invest in your free time.'), 'tab' => 'Personal', 'type' => Settings::get('per_typ_4', 'textarea')], 'profile[pro_text_1]' => ['label' => Settings::get('pro_label_1', 'Position'), 'comment' => Settings::get('pro_desc_1', 'Your current job title.'), 'tab' => 'Professional', 'type' => Settings::get('pro_typ_1', 'text')], 'profile[pro_text_2]' => ['label' => Settings::get('pro_label_2', 'Assignment'), 'comment' => Settings::get('pro_desc_2', 'Where are you working now.'), 'tab' => 'Professional', 'type' => Settings::get('pro_typ_2', 'text')], 'profile[pro_text_3]' => ['label' => Settings::get('pro_label_3', 'Accomplishments'), 'comment' => Settings::get('pro_desc_3', 'The positive things you have done so far.'), 'tab' => 'Professional', 'type' => Settings::get('pro_typ_3', 'textarea')], 'profile[pro_text_4]' => ['label' => Settings::get('pro_label_4', 'Future Goals'), 'comment' => Settings::get('pro_desc_4', 'The things you want to accomplish in the next year or more.'), 'tab' => 'Professional', 'type' => Settings::get('pro_typ_4', 'textarea')]]);
     });
     Event::listen('backend.menu.extendItems', function ($manager) {
         $manager->addSideMenuItems('RainLab.User', 'user', ['merge' => ['label' => 'Merge', 'icon' => 'icon-exchange', 'code' => 'merge', 'owner' => 'RainLab.User', 'url' => Backend::url('kurtjensen/profile/merge'), 'permissions' => ['kurtjensen.profile.merge']]]);
     });
 }
示例#3
0
 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()
 {
     UserController::extend(function ($controller) {
         $controller->implement[] = 'VojtaSvoboda.UserExportPdf.Behaviors.PdfExportBehavior';
     });
     // extend user listing
     Event::listen('backend.list.extendColumns', function ($widget) {
         // Only for the User controller
         if (!$widget->getController() instanceof UserController) {
             return;
         }
         // Only for the User model
         if (!$widget->model instanceof UserModel) {
             return;
         }
         // Add an extra birthday column
         $widget->addColumns(['export' => ['label' => 'vojtasvoboda.userexportpdf::lang.list.export.column', 'sortable' => false, 'clickable' => false]]);
     });
     // extend export column value to add export button
     Event::listen('backend.list.overrideColumnValue', function ($widget, $model, $column, $value) {
         // Only for the User model
         if (!$model instanceof UserModel) {
             return;
         }
         if ($column->columnName == 'export') {
             $button = '<a';
             $button .= ' href="' . url('/backend/rainlab/user/users/pdf/' . $model->id) . '"';
             $button .= ' class="btn btn-xs btn-warning"';
             $button .= '>' . Lang::get('vojtasvoboda.userexportpdf::lang.list.export.button') . '</a>';
             return $button;
         }
     });
 }
 public function boot()
 {
     UsersController::extendFormFields(function ($form, $model, $context) {
         if (!$model instanceof UserModel) {
             return;
         }
         $form->addTabFields(['iu_gender' => ['label' => 'indikator.user::lang.personal.gender', 'tab' => 'indikator.user::lang.personal.tab', 'type' => 'dropdown', 'options' => ['unknown' => Lang::get('indikator.user::lang.gender.unknown'), 'female' => Lang::get('indikator.user::lang.gender.female'), 'male' => Lang::get('indikator.user::lang.gender.male')], 'span' => 'auto'], 'iu_job' => ['label' => 'indikator.user::lang.personal.job', 'tab' => 'indikator.user::lang.personal.tab', 'span' => 'auto'], 'iu_about' => ['label' => 'indikator.user::lang.personal.about', 'tab' => 'indikator.user::lang.personal.tab', 'type' => 'textarea', 'size' => 'small', 'span' => 'full'], 'iu_webpage' => ['label' => 'indikator.user::lang.internet.webpage', 'tab' => 'indikator.user::lang.internet.tab', 'span' => 'auto'], 'iu_blog' => ['label' => 'indikator.user::lang.internet.blog', 'tab' => 'indikator.user::lang.internet.tab', 'span' => 'auto'], 'iu_facebook' => ['label' => 'indikator.user::lang.internet.facebook', 'tab' => 'indikator.user::lang.internet.tab', 'span' => 'auto'], 'iu_twitter' => ['label' => 'indikator.user::lang.internet.twitter', 'tab' => 'indikator.user::lang.internet.tab', 'span' => 'auto'], 'iu_skype' => ['label' => 'indikator.user::lang.internet.skype', 'tab' => 'indikator.user::lang.internet.tab', 'span' => 'auto'], 'iu_icq' => ['label' => 'indikator.user::lang.internet.icq', 'tab' => 'indikator.user::lang.internet.tab', 'span' => 'auto'], 'iu_comment' => ['label' => 'indikator.user::lang.comment', 'tab' => 'rainlab.user::lang.user.account', 'type' => 'textarea', 'size' => 'small', 'span' => 'full']]);
     });
 }
示例#6
0
 public function boot()
 {
     UserModel::extend(function ($model) {
         $model->addFillable(['phone', 'mobile', 'company', 'street_addr', 'city', 'zip']);
         $model->implement[] = 'RainLab.Location.Behaviors.LocationModel';
     });
     UsersController::extendFormFields(function ($widget) {
         $configFile = __DIR__ . '/config/profile_fields.yaml';
         $config = Yaml::parse(File::get($configFile));
         $widget->addTabFields($config);
     });
 }
示例#7
0
 public function boot()
 {
     UserModel::extend(function ($model) {
         $model->addFillable(['phone', 'mobile', 'company', 'street_addr', 'city', 'zip']);
         $model->implement[] = 'RainLab.Location.Behaviors.LocationModel';
     });
     UsersController::extendFormFields(function ($widget) {
         // Prevent extending of related form instead of the intended User form
         if (!$widget->model instanceof UserModel) {
             return;
         }
         $configFile = __DIR__ . '/config/profile_fields.yaml';
         $config = Yaml::parse(File::get($configFile));
         $widget->addTabFields($config);
     });
 }
示例#8
0
 public function boot()
 {
     UserModel::extend(function ($model) {
         $model->hasOne['profile'] = ['Acme\\Profile\\Models\\Profile'];
     });
     UsersController::extendFormFields(function ($form, $model, $context) {
         if (!$model instanceof UserModel) {
             return;
         }
         if (!$model->exists) {
             return;
         }
         // To ensure a user profile always exists
         ProfileModel::getFromUser($model);
         $form->addTabFields(['profile[username]' => ['label' => 'Username', 'tab' => 'Profile', 'type' => 'text'], 'profile[bio]' => ['label' => 'About Yourself', 'tab' => 'Profile', 'type' => 'textarea'], 'profile[favourite_team]' => ['label' => 'Your Favourite Team', 'tab' => 'Profile', 'type' => 'text'], 'profile[nationality]' => ['label' => 'Nationality', 'tab' => 'Profile', 'type' => 'text'], 'profile[position]' => ['label' => 'Favourite Player Position', 'tab' => 'Profile', 'type' => 'text'], 'profile[fan_type]' => ['label' => 'What sort of fan are you?', 'tab' => 'Profile', 'type' => 'text']]);
     });
 }
示例#9
0
 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]]);
     });
 }