src/Html/Options/HasColumns.php
public function columns(array $columns)
    {
        $this->collection = new Collection;

        foreach ($columns as $key => $value) {
            if (! is_a($value, Column::class)) {
                if (is_array($value)) {
                    $attributes = array_merge(
                        [
                            'name' => $value['name'] ?? $value['data'] ?? $key,
                            'data' => $value['data'] ?? $key,
                        ],
                        $this->setTitle($key, $value)
                    );
                } else {
                    $attributes = [
                        'name' => $value,
                        'data' => $value,
                        'title' => $this->getQualifiedTitle($value),
                    ];
                }

                $this->collection->push(new Column($attributes));
            } else {
                $this->collection->push($value);
            }
        }

        return $this;
    }
public function columns(array $columns)
    {
        $this->collection = new Collection;

        foreach ($columns as $key => $value) {
            if (! is_a($value, Column::class)) {
                if (is_array($value)) {
                    $attributes = array_merge(
                        [
                            'name' => $value['name'] ?? $value['data'] ?? $key,
                            'data' => $value['data'] ?? $key,
                        ],
                        $this->setTitle($key, $value)
                    );
                } else {
                    $attributes = [
                        'name' => $value,
                        'data' => $value,
                        'title' => $this->getQualifiedTitle($value),
                    ];
                }

                $this->collection->push(new Column($attributes));
            } else {
                $this->collection->push($value);
            }
        }

        return $this;
    }
public function columns ( array $ columns ) { $ this -> collection = new Collection ; foreach ( $ columns as $ key => $ value ) { if ( ! is_a ( $ value , Column :: class ) ) { if ( is_array ( $ value ) ) { $ attributes = array_merge ( [ 'name' => $ value [ 'name' ] ?? $ value [ 'data' ] ?? $ key , 'data' => $ value [ 'data' ] ?? $ key , ] , $ this -> setTitle ( $ key , $ value ) ) ; } else { $ attributes = [ 'name' => $ value , 'data' => $ value , 'title' => $ this -> getQualifiedTitle ( $ value ) , ] ; } $ this -> collection -> push ( new Column ( $ attributes ) ) ; } else { $ this -> collection -> push ( $ value ) ; } } return $ this ; }
Set columns option value.

@param array $columns
@return $this
@see https://datatables.net/reference/option/columns
Set columns option value .