foreach ($templates as $name => $template) {
$options[Str::snake($name)] = $template->getName();
}
+
+ asort($options); // Alphabetically sort templates by their display names
+
$this->setAttribute('options', $options);
}
}
$inst = new $modelClass();
$attr=$this->getAttribute('attribute');
- return $modelClass::orderBy($attr)->get()->pluck($attr, $inst->getPrimaryKey())->toArray();
+ // Allow the attribute to be a custom accessor.
+ // For this to work, the query is done first, then the Collection object handles it
+ // Ref: https://stackoverflow.com/a/44475575
+ return $modelClass::get()->sortBy($attr)->pluck($attr, $inst->getPrimaryKey())->toArray();
}
public function getDatabaseType()