field; } public function getDirection(): SortDirection { return $this->direction; } /** * Build the enum case for a direction. * Template: {FIELD_NAME}. * Template: {FIELD_NAME}_DESC. */ public function __toString(): string { $name = Str::of($this->field->getName()) ->snake() ->upper(); return (string) match ($this->direction) { SortDirection::ASC => $name, SortDirection::DESC => $name->append('_DESC'), }; } /** * Apply the ordering to the current Eloquent builder. */ abstract public function sort(Builder $builder): Builder; }