Beispiel #1
0
 private function registerRelation($model, $relation)
 {
     Store::pushIfNotPresent('relation_' . $relation, ['model' => strtolower(get_class($this)), 'target' => $model]);
     $type = $relation == 'belongs_to' ? 'list' : 'checkbox_list';
     return ['type' => $type, 'label' => ucfirst($model), 'options' => function () use($model) {
         $arr = [];
         $items = call_user_func(ucfirst($model) . '::find');
         foreach ($items as $item) {
             $arr[$item->ID] = $item->title;
         }
         return $arr;
     }];
 }