-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Beta Fixes - Publishing Views/Localizations. Beta Improvements - Sear…
…ch Options (#1324) * Update setSearchDebounce, add setSearchThrottle/setSearchBlur * Remove Lazy Test * Remove Lazy Tests - Update Docs * Update Views Publish Path * Add Translations Publish Option * Update ChangeLog * Add Reusable Columns * Add Tests for Prepend/Append Cols --------- Co-authored-by: lrljoe <[email protected]>
- Loading branch information
Showing
12 changed files
with
202 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
title: Reusable Columns | ||
weight: 8 | ||
--- | ||
|
||
Often you will want to re-use the same column across multiple tables. For example a "Created At" and "Used At" column. | ||
|
||
To mitigate the pain of maintaining this, two new methods have been introduced. | ||
|
||
These methods both function in exactly the same way as your standard columns(), and expect an array of columns. | ||
|
||
Any columns defined in prependColumns() will be the first columns in your list of columns. | ||
``` | ||
public function prependColumns(): array | ||
{ | ||
return []; | ||
} | ||
``` | ||
|
||
Any columns defined in appendColumns() will be the last columns in your list of columns. | ||
``` | ||
public function appendColumns(): array | ||
{ | ||
return []; | ||
} | ||
``` | ||
|
||
You can call these in your trait, and they will be automatically appended/prepended to tables. | ||
|
||
For example, to append a Column for Updated At | ||
``` | ||
public function appendColumns(): array | ||
{ | ||
return [ | ||
Column::make('Updated At', 'updated_at'), | ||
]; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Configuration; | ||
|
||
use Rappasoft\LaravelLivewireTables\Views\Column; | ||
|
||
trait ColumnConfiguration | ||
{ | ||
public function setPrependedColumns(array $prependedColumns): void | ||
{ | ||
$this->prependedColumns = collect($prependedColumns) | ||
->filter(fn ($column) => $column instanceof Column) | ||
->map(function (Column $column) { | ||
$column->setComponent($this); | ||
|
||
if ($column->hasField()) { | ||
if ($column->isBaseColumn()) { | ||
$column->setTable($this->getBuilder()->getModel()->getTable()); | ||
} else { | ||
$column->setTable($this->getTableForColumn($column)); | ||
} | ||
} | ||
|
||
return $column; | ||
}); | ||
} | ||
|
||
public function setAppendedColumns(array $appendedColumns): void | ||
{ | ||
$this->appendedColumns = collect($appendedColumns) | ||
->filter(fn ($column) => $column instanceof Column) | ||
->map(function (Column $column) { | ||
$column->setComponent($this); | ||
|
||
if ($column->hasField()) { | ||
if ($column->isBaseColumn()) { | ||
$column->setTable($this->getBuilder()->getModel()->getTable()); | ||
} else { | ||
$column->setTable($this->getTableForColumn($column)); | ||
} | ||
} | ||
|
||
return $column; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters