PHP code example of outl1ne / nova-detached-filters
1. Go to this page and download the library: Download outl1ne/nova-detached-filters library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
outl1ne / nova-detached-filters example snippets
use Outl1ne\NovaDetachedFilters\NovaDetachedFilters;
public function filters()
{
return $this->myFilters();
}
public function cards()
{
return [
new NovaDetachedFilters($this->myFilters()),
];
}
protected function myFilters()
{
return [
new BooleanFilter(),
new SelectFilter(),
new PillFilter(),
// ...
];
}
use Outl1ne\NovaDetachedFilters\NovaDetachedFilters;
use \Outl1ne\NovaDetachedFilters\HasDetachedFilters;
class ExampleResource extends Resource
{
use HasDetachedFilters; // Needs to have this trait
public function cards()
{
return [
new NovaDetachedFilters([
new SelectFilter, // Showed only on card
new SelectFilter2, // Showed both in dropdown menu and on card
]),
];
}
public function filters()
{
return [
new SelectFilter2, // Showed both in dropdown menu and on card
new SelectFilter3 // Shown only in dropdown menu
];
}
}
public function cards(Request $request)
{
return [
new NovaDetachedFilters([
(new SelectFilter())->withMeta(['width' => 'w-1/3']),
(new AnotherSelectFilter())->withMeta(['width' => 'w-2/3']),
]),
];
}
public function cards(Request $request)
{
return [
(new NovaDetachedFilters([
new SelectFilter(),
new AnotherSelectFilter()
]))->width('1/3'),
(new NovaDetachedFilters([
new SelectFilter(),
new AnotherSelectFilter()
]))->width('2/3'),
];
}
public function cards(Request $request)
{
return [
new NovaDetachedFilters([
(new SelectFilter())->withMeta(['withReset' => true]),
]),
];
}
public function cards(Request $request)
{
return [
(new NovaDetachedFilters([
new SelectFilter(),
]))->withReset(),
];
}
public function cards(Request $request)
{
return [
(new NovaDetachedFilters([
new SelectFilter(),
]))->persistFilters(),
];
}
public function cards(Request $request)
{
return [
(new NovaDetachedFilters([
new SelectFilter(),
]))->withToggle(),
];
}
public function cards(Request $request)
{
return [
new NovaDetachedFilters([
new BooleanFilter(),
new DetachedFilterColumn([
new SelectFilter(),
new SelectFilter(),
new SelectFilter(),
new SelectFilter()
], 'w-2/3'),
]),
];
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.