Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom view prepend #1036

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion docs/misc/custom-markup.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,15 @@ public function customView(): string
{
return 'includes.custom';
}
```
```

If you would like to append any custom markup right before the start of the component, you may use the `customViewPrepend` method and return a view.

This is good for loading extra content such as dismissible alerts or flash notifications.

```php
public function customViewPrepend(): string
{
return 'includes.custom';
}
```
3 changes: 3 additions & 0 deletions resources/views/datatable.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<x-livewire-tables::wrapper :component="$this">
@isset($customViewPrepend)
@include($customViewPrepend)
@endisset
<x-livewire-tables::tools>
<x-livewire-tables::tools.sorting-pills />
<x-livewire-tables::tools.filter-pills />
Expand Down
Empty file.
16 changes: 14 additions & 2 deletions src/DataTableComponent.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function boot(): void
'filters' => $this->{$this->tableName}['filters'] ?? [],
'columns' => $this->{$this->tableName}['columns'] ?? [],
];

// Set the filter defaults based on the filter type
$this->setFilterDefaults();
}
Expand Down Expand Up @@ -122,7 +122,18 @@ public function customView(): string
{
return 'livewire-tables::stubs.custom';
}



/**
* The view to add any html before the table
*
* @return string
*/
public function customViewPrepend(): string
{
return 'livewire-tables::stubs.custom-prepend';
}

/**
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\Contracts\View\View
*/
Expand All @@ -139,6 +150,7 @@ public function render()
'columns' => $this->getColumns(),
'rows' => $this->getRows(),
'customView' => $this->customView(),
'customViewPrepend' => $this->customViewPrepend(),
]);
}
}