Пример #1
0
 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']]);
         });
     }
 }