Code Duplication    Length = 16-16 lines in 2 locations

src/Form/Elements/Select.php 1 location

@@ 90-105 (lines=16) @@
87
     *
88
     * @return array
89
     */
90
    protected function setOptionsFromModel()
91
    {
92
        $model = $this->getOptionsModel();
93
94
        $key = $this->getOptionsValueAttribute() ?: $model->getKeyName();
95
96
        $repository = app(RepositoryInterface::class);
97
        $repository->setModel($model);
98
        $query = $repository->getQuery();
99
100
        $results = $query->get();
101
        if (is_null(($label = $this->getOptionsLabelAttribute()))) {
102
            throw new InvalidArgumentException('Form select element must set label attribute');
103
        }
104
        return $results->pluck($this->getOptionsLabelAttribute(), $key);
105
    }
106
107
    /**
108
     * @return Model

src/Form/Elements/Tree.php 1 location

@@ 99-114 (lines=16) @@
96
     *
97
     * @return array
98
     */
99
    protected function setOptionsFromModel()
100
    {
101
        $model = $this->getOptionsModel();
102
103
        $key = $this->getOptionsValueAttribute() ?: $model->getKeyName();
104
105
        $repository = app(RepositoryInterface::class);
106
        $repository->setModel($model);
107
        $query = $repository->getQuery();
108
109
        $results = $query->get();
110
        if (is_null(($label = $this->getOptionsLabelAttribute()))) {
111
            throw new InvalidArgumentException('Form select element must set label attribute');
112
        }
113
        return $results->pluck($this->getOptionsLabelAttribute(), $key);
114
    }
115
116
    /**
117
     * @return Model