当前位置: 首页>>代码示例>>PHP>>正文


PHP User::extend方法代码示例

本文整理汇总了PHP中RainLab\User\Models\User::extend方法的典型用法代码示例。如果您正苦于以下问题:PHP User::extend方法的具体用法?PHP User::extend怎么用?PHP User::extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RainLab\User\Models\User的用法示例。


在下文中一共展示了User::extend方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: boot

 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]]);
     });
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:28,代码来源:Plugin.php

示例2: boot

 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']]]);
     });
 }
开发者ID:aydancoskun,项目名称:octobercms,代码行数:29,代码来源:Plugin.php

示例3: boot

 public function boot()
 {
     User::extend(function ($model) {
         $model->hasMany['flynsarmy_sociallogin_providers'] = ['Flynsarmy\\SocialLogin\\Models\\Provider'];
     });
     Event::listen('backend.form.extendFields', function (Form $form) {
         if (!$form->getController() instanceof \System\Controllers\Settings) {
             return;
         }
         if (!$form->model instanceof \Flynsarmy\SocialLogin\Models\Settings) {
             return;
         }
         foreach (ProviderManager::instance()->listProviders() as $class => $details) {
             $classObj = $class::instance();
             $classObj->extendSettingsForm($form);
         }
     });
     Event::listen('backend.form.extendFields', function ($widget) {
         if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
             return;
         }
         if ($widget->getContext() != 'update') {
             return;
         }
         $widget->addFields(['flynsarmy_sociallogin_providers' => ['label' => 'Social Providers', 'type' => 'Flynsarmy\\SocialLogin\\FormWidgets\\LoginProviders']], 'secondary');
     });
 }
开发者ID:jiiis,项目名称:ptn,代码行数:27,代码来源:Plugin.php

示例4: boot

 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);
     });
 }
开发者ID:abnmt,项目名称:oc-mrc-plugin,代码行数:32,代码来源:Plugin.php

示例5: boot

 public function boot()
 {
     App::register('Laravel\\Cashier\\CashierServiceProvider');
     Config::set('services.stripe.model', 'RainLab\\User\\Models\\User');
     Config::set('services.stripe.secret', Settings::get('stripe_secret'));
     User::extend(function ($model) {
         $model->implement[] = 'Alxy.Cashier.Behaviors.BillableModel';
     });
 }
开发者ID:chrisvidal,项目名称:oc-cashier-plugin,代码行数:9,代码来源:Plugin.php

示例6: boot

 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);
     });
 }
开发者ID:creativemonday,项目名称:FbHack,代码行数:12,代码来源:Plugin.php

示例7: boot

 public function boot()
 {
     UserModel::extend(function ($model) {
         $model->addFillable(['iu_gender', 'iu_telephone', 'iu_job', 'iu_company', 'iu_about', 'iu_webpage', 'iu_blog', 'iu_facebook', 'iu_twitter', 'iu_skype', 'iu_icq', 'iu_comment']);
     });
     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_telephone' => ['label' => 'indikator.user::lang.personal.telephone', 'tab' => 'indikator.user::lang.personal.tab', 'span' => 'auto'], 'iu_job' => ['label' => 'indikator.user::lang.personal.job', 'tab' => 'indikator.user::lang.personal.tab', 'span' => 'auto'], 'iu_company' => ['label' => 'indikator.user::lang.personal.company', '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']]);
         $form->addSecondaryTabFields(['iu_comment' => ['label' => 'indikator.user::lang.comment', 'type' => 'textarea', 'size' => 'small']]);
     });
 }
开发者ID:TomaszN007,项目名称:oc-user-plus,代码行数:13,代码来源:Plugin.php

示例8: boot

 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);
     });
 }
开发者ID:rainlab,项目名称:userplus-plugin,代码行数:16,代码来源:Plugin.php

示例9: boot

 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']]);
     });
 }
开发者ID:JohnathanBere,项目名称:5aSideGDP,代码行数:17,代码来源:Plugin.php

示例10: boot

 /**
  * {@inheritDoc}
  */
 public function boot()
 {
     // Extend Activity model to support extra fields & ratings
     Activity::extend(function ($model) {
         $model->hasOne['activity_fields'] = ['DenverArt\\ActivityFields\\Models\\ExtraFields'];
         $model->hasMany['ratings'] = ['DenverArt\\ActivityFields\\Models\\Rating'];
         $model->addDynamicMethod('scopeNotIgnored', function ($query, $user) {
             $query = $query->whereHas('ratings', function ($q) use($user) {
                 $q->where('user_id', $user->getKey())->where('rating', 0);
             }, '<', 1);
         });
         $model->addDynamicMethod('scopeIgnored', function ($query, $user) {
             $query = $query->whereHas('ratings', function ($q) use($user) {
                 $q->where('user_id', $user->getKey())->where('rating', 0);
             });
         });
         $model->addDynamicMethod('scopeNotComplete', function ($query, $user) {
             $query = $query->whereHas('users', function ($q) use($user) {
                 $q->where('user_id', $user->getKey());
             }, '<', 1);
         });
         $model->addDynamicMethod('scopeComplete', function ($query, $user) {
             $query = $query->whereHas('users', function ($q) use($user) {
                 $q->where('user_id', $user->getKey());
             });
         });
     });
     // Extend User model to support ratings
     User::extend(function ($model) {
         $model->hasMany['ratings'] = ['DenverArt\\ActivityFields\\Models\\Rating'];
     });
     // Extend Activity fields
     $context = $this;
     Event::listen('backend.form.extendFields', function ($widget) use($context) {
         $context->extendedActivityFields($widget);
     });
     // Extend Activity admin listing table columns
     Event::listen('backend.list.extendColumns', function ($widget) {
         if (!$widget->getController() instanceof \DMA\Friends\Controllers\Activities) {
             return;
         }
         $widget->addColumns(['duration' => ['label' => 'Duration', 'relation' => 'activity_fields', 'sortable' => true, 'select' => '@duration', 'searchable' => true], 'location' => ['label' => 'Location', 'relation' => 'activity_fields', 'sortable' => true, 'select' => '@location', 'searchable' => true]]);
     });
 }
开发者ID:janusnic,项目名称:ActivityFields,代码行数:47,代码来源:Plugin.php

示例11: boot

 public function boot()
 {
     User::extend(function ($model) {
         $model->belongsToMany['groups'] = ['ShahiemSeymor\\Roles\\Models\\UserGroup', 'table' => 'shahiemseymor_assigned_roles', 'foreignKey' => 'role_id'];
         $model->belongsToMany['permissions'] = ['ShahiemSeymor\\Roles\\Models\\UserGroup', 'table' => 'shahiemseymor_assigned_roles', 'foreignKey' => 'role_id'];
     });
     $userGroup = new UserGroup();
     $userGroup->newUserAddToDefaultGroup();
     Event::listen('backend.menu.extendItems', function ($manager) {
         $manager->addSideMenuItems('RainLab.User', 'user', ['roles' => ['label' => 'Roles', 'icon' => 'icon-users', 'code' => 'roles', 'owner' => 'RainLab.User', 'url' => Backend::url('shahiemseymor/roles/groups')], 'perms' => ['label' => 'Permissions', 'icon' => 'icon-key', 'code' => 'perms', 'owner' => 'RainLab.User', 'url' => Backend::url('shahiemseymor/roles/permissions')]]);
     });
     Event::listen('backend.form.extendFields', function ($widget) {
         if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
             return;
         }
         if (!$widget->model instanceof \RainLab\User\Models\User) {
             return;
         }
         $widget->addFields(['groups' => ['label' => 'Roles', 'tab' => 'Groups', 'type' => 'relation']], 'primary');
     });
 }
开发者ID:janusnic,项目名称:OctoberCMS,代码行数:21,代码来源:Plugin.php

示例12: boot

 public function boot()
 {
     $manager = PluginManager::instance();
     if ($manager->exists('rainlab.user')) {
         User::extend(function ($model) {
             $model->hasMany['mycalevents'] = ['KurtJensen\\MyCalendar\\Models\\Events', 'table' => 'kurtjensen_mycal_events'];
         });
         EventModel::extend(function ($model) {
             $model->belongsTo['user'] = ['RainLab\\User\\Models\\User', 'table' => 'user', 'key' => 'user_id', 'otherKey' => 'id'];
         });
         EventController::extendFormFields(function ($form, $model, $context) {
             if (!$model instanceof EventModel) {
                 return;
             }
             $form->addFields(['user_id' => ['label' => 'kurtjensen.mycalendar::lang.event.user_id', 'type' => 'dropdown', 'span' => 'right']]);
         });
         EventController::extendListColumns(function ($lists, $model) {
             $lists->addColumns(['fname' => ['label' => 'kurtjensen.mycalendar::lang.event.fname', 'relation' => 'user', 'select' => 'name', 'searchable' => 'true', 'sortable' => 'true'], 'lname' => ['label' => 'kurtjensen.mycalendar::lang.event.lname', 'relation' => 'user', 'select' => 'surname', 'searchable' => 'true', 'sortable' => 'true']]);
         });
     }
 }
开发者ID:ribsousa,项目名称:MyCalendar,代码行数:21,代码来源:Plugin.php

示例13: boot

 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]]);
     });
 }
开发者ID:janusnic,项目名称:OctoberCMS,代码行数:21,代码来源:Plugin.php

示例14: boot

 public function boot()
 {
     Session::extend(function ($component) {
         /* @var $component Session */
     });
     User::extend(function ($model) {
         /* @var $model User */
         $model->belongsToMany['groups'] = ['BnB\\UserGroup\\Models\\UserGroup', 'table' => 'users_groups'];
     });
     Event::listen('backend.menu.extendItems', function ($manager) {
         $manager->addSideMenuItems('RainLab.User', 'user', ['groups' => ['label' => 'bnb.usergroup::lang.groups.all_groups', 'icon' => 'icon-users', 'url' => Backend::url('bnb/usergroup/usergroups'), 'permissions' => ['rainlab.groups.access_groups']]]);
     });
     Event::listen('backend.form.extendFields', function ($widget) {
         //Extend groups controller
         if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
             return;
         }
         if (!$widget->model instanceof \RainLab\User\Models\User) {
             return;
         }
         $widget->addTabFields(['groups' => ['label' => trans('bnb.usergroup::lang.user.groups'), 'comment' => trans('bnb.usergroup::lang.user.groups_comment'), 'type' => 'relation', 'tab' => 'bnb.usergroup::lang.user.groups', 'span' => 'auto']]);
     });
 }
开发者ID:gabsource,项目名称:usergroup-plugin,代码行数:23,代码来源:Plugin.php

示例15: boot

 /**
  * Boot method, called right before the request route.
  *
  * @return array
  */
 public function boot()
 {
     User::extend(function ($model) {
         $model->hasMany['notifications'] = ['Autumn\\Notifications\\Models\\NotificationUser'];
     });
 }
开发者ID:gpasztor87,项目名称:oc-notifications-plugin,代码行数:11,代码来源:Plugin.php


注:本文中的RainLab\User\Models\User::extend方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。