Skip to content

Commit cd136aa

Browse files
authored
Add IncrementColumn
1 parent bce91a4 commit cd136aa

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@aware(['rowIndex'])
2+
<div {!! count($attributes) ? $column->arrayToAttributes($attributes) : '' !!}>{{ $rowIndex+1 }}</div>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace Rappasoft\LaravelLivewireTables\Views\Columns;
4+
5+
use Illuminate\Database\Eloquent\Model;
6+
use Rappasoft\LaravelLivewireTables\Exceptions\DataTableConfigurationException;
7+
use Rappasoft\LaravelLivewireTables\Views\Column;
8+
9+
class IncrementColumn extends Column
10+
{
11+
12+
protected string $view = 'livewire-tables::includes.columns.increment';
13+
14+
public function __construct(string $title, ?string $from = null)
15+
{
16+
parent::__construct($title, $from);
17+
$this->label(fn () => null);
18+
19+
}
20+
21+
public function getContents(Model $row): null|string|\Illuminate\Support\HtmlString|DataTableConfigurationException|\Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
22+
{
23+
return view($this->getView())
24+
->withColumn($this)
25+
->withIsTailwind($this->isTailwind())
26+
->withIsBootstrap($this->isBootstrap())
27+
->withAttributes($this->hasAttributesCallback() ? app()->call($this->getAttributesCallback(), ['row' => $row]) : []);
28+
}
29+
}

0 commit comments

Comments
 (0)