@foreach ($table->availableFilters as $filterKey => $filter)
@@ -66,11 +66,11 @@
-
+
-
-
+
+
@foreach($table->columns as $column)
@@ -78,8 +78,9 @@
{{ $column['label'] }}
|
- @else
-
+ @endif
+ @if ($loop->last)
+ |
{{ $column['label'] }}
|
@endif
@@ -89,17 +90,20 @@
@foreach($table->rows as $row)
- @foreach($table->columns as $columnKey => $columnValue)
- @if ($loop->first)
-
- {{ $row[$columnKey] }}
+ |
+ {{ collect($row)->first() }}
+
+ @foreach($table->columns as $columnKey => $columnValue)
+ @if (!$loop->last)
+ - {{ $columnValue['label'] }}
+ - {{ $row[$columnKey] }}
+ @endif
+ @endforeach
+
|
- @else
-
- {{ $row[$columnKey] }}
+ |
+ {{ collect($row)->last() }}
|
- @endif
- @endforeach
@endforeach
@@ -108,6 +112,27 @@
+
+
+
+ Updating data...
+
+
\ No newline at end of file
diff --git a/src/DefaultTable.php b/src/DefaultTable.php
index 4357e7b..61c81c3 100644
--- a/src/DefaultTable.php
+++ b/src/DefaultTable.php
@@ -56,7 +56,7 @@ protected function getRows()
{
$faker = \Faker\Factory::create();
- return collect(range(1, 100))->map(function ($i) use ($faker) {
+ return collect(range(1, 1000))->map(function ($i) use ($faker) {
return [
'name' => $faker->name,
'email' => $faker->email,
diff --git a/src/TableTileComponent.php b/src/TableTileComponent.php
index fbb9490..06c7135 100644
--- a/src/TableTileComponent.php
+++ b/src/TableTileComponent.php
@@ -37,7 +37,21 @@ class TableTileComponent extends Component
*/
public int $refreshIntervalInSeconds;
+ /**
+ * The table instance.
+ *
+ * @var mixed
+ */
+ protected $table;
+ /**
+ * Mounts the component
+ *
+ * @param string $position
+ * @param string $tableClass
+ * @param int $refreshIntervalInSeconds
+ * @return void
+ */
public function mount(
string $position,
string $tableClass = null,
@@ -54,14 +68,39 @@ public function mount(
$this->state['filters'] = collect($table->availableFilters)->mapWithKeys(function ($filter, $key) {
return [$key => []];
})->toArray();
+
+ $this->table = new $this->tableClass(
+ $this->state['filters'],
+ $this->state['query'],
+ );
}
+ /**
+ * Calculates current filters count.
+ *
+ * @return int
+ */
public function getFilterCountProperty()
{
return collect($this->state['filters'])->map(function ($filter) {
return count($filter);
})->sum();
}
+
+ /**
+ * Runs when the filters are updated.
+ *
+ * @param mixed $value
+ * @param mixed $key
+ * @return void
+ */
+ public function updatedState($value, $key)
+ {
+ $this->table = new $this->tableClass(
+ $this->state['filters'],
+ $this->state['query'],
+ );
+ }
public function render()
{