nova-page
nova-page copied to clipboard
Added novaPageIndexQuery to StaticResource to mimic indexQuery
I've added a method novaPageIndexQuery
to Whitecube\NovaPage\Pages\StaticResource
which allows someone to manipulate the Whitecube\NovaPage\Pages\Query
on the nova index page. It's intended to mimic the indexQuery
method.
I've also added the methodWhitecube\NovaPage\Pages\Query::sortBy
to allow simple sorting.
It might work better just having a generic callback (e.g. $query->setCallback(...)
) which gets applied to the Collection in Whitecube\NovaPage\Pages\Query::get
.
~Should merge in conjunction with https://github.com/whitecube/nova-page/pull/45~ merged
Closes
https://github.com/whitecube/nova-page/issues/44 (sorta)
Usage
Configure your own config novapage.default_page_resource
in config/novapage.php
'default_page_resource' => \App\Nova\Page::class,
<?php
namespace App\Nova;
use Whitecube\NovaPage\Pages\PageResource;
use Whitecube\NovaPage\Pages\Query;
class Page extends PageResource
{
public static function novaPageIndexQuery(Query $query)
{
return $query->orderBy(function ($item) {
return $item->getTitle();
}, 'ASC');
}
}