Skip to content
Discussion options

You must be logged in to vote

Stack fields already support sorting by setting the attribute as the second argument:

Stack::make('Employee', 'employee', [
    Text::make('Name')->sortable(),
    Text::make('Surname')->sortable(),
]),
/**
 * Create a new Stack field.
 *
 * @param  string  $name
 * @param  string|array<int, class-string<\Laravel\Nova\Fields\Field>|callable>|null  $attribute
 * @param  array<int, class-string<\Laravel\Nova\Fields\Field>|callable>  $lines
 * @return void
 */
public function __construct($name, $attribute = null, $lines = [])
{
    if (is_array($attribute)) {
        $lines = $attribute;
        $attribute = null;
    }

    parent::__construct($name, $attribute);

    $this->lines = $lines;
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@fabiov
Comment options

Answer selected by davidhemphill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants