Skip to content

Commit c6cc9a7

Browse files
committed
Allow array for orthogonal column data
yajra/laravel-datatables#2380
1 parent 30f7cb4 commit c6cc9a7

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/Html/Column.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Yajra\DataTables\Html\Options\Plugins\SearchPanes;
99

1010
/**
11-
* @property string $data
11+
* @property array|string $data
1212
* @property string $name
1313
* @property string $title
1414
* @property string $titleAttr
@@ -311,11 +311,12 @@ public function width(int|string $value): static
311311
/**
312312
* Set column data option value.
313313
*
314-
* @param string $value
314+
* @param array|string $value
315315
* @return $this
316316
* @see https://datatables.net/reference/option/columns.data
317+
* @see https://datatables.net/manual/data/orthogonal-data
317318
*/
318-
public function data(string $value): static
319+
public function data(array|string $value): static
319320
{
320321
$this->attributes['data'] = $value;
321322

tests/ColumnTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,18 @@ public function it_can_render_scripts()
155155
$column->renderRaw('test');
156156
$this->assertEquals('test', $column->render);
157157
}
158+
159+
/** @test */
160+
public function it_allows_orthogonal_data()
161+
{
162+
$expected = [
163+
'_' => 'test',
164+
'sort' => 'test',
165+
'filter' => 'test',
166+
'type' => 'test',
167+
];
168+
$column = Column::make('name')->data($expected);
169+
170+
$this->assertEquals($expected, $column->data);
171+
}
158172
}

0 commit comments

Comments
 (0)