-
-
Notifications
You must be signed in to change notification settings - Fork 46
Added novaPageIndexQuery to StaticResource to mimic indexQuery #46
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
base: master
Are you sure you want to change the base?
Conversation
…the QueriesResource Concern to mimic the core indexQuery method. Added a orderBy method to the Query to allow control ordering.
Merge whitecube/nova-page#master into rapidz/nova-page#resource-index-query
toonvandenbos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @GarethSomers,
Thanks for the PR. It seems good to me, I just found two little points I'd love to see enhanced :
- Could you add & document the 2 new configuration keys into
src/config.php? - As shown in my previous review comment, the configuration values could not exist when upgrading an existing Nova project, meaning we should provide default values on lines 58 & 59 of
src/Pages/Concerns/QueriesResources.php.
Thanks !
|
|
||
| protected function applyIndexQueryForType($type, Query $query) { | ||
| $page_resource_class = config('novapage.default_page_resource'); | ||
| $option_resource_class = config('novapage.default_option_resource'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both config() calls should default to the provided Resource classes in case the config file does not (yet) contain the default_page_resource or default_option_resource keys in order to ensure update compatibility.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Nyratas I've added documentation docs/README.md and I've set the default values in src/Pages/Concerns/QueriesResources.php .
Let me know if there's anything I've missed. Thanks!
I've added a method
novaPageIndexQuerytoWhitecube\NovaPage\Pages\StaticResourcewhich allows someone to manipulate theWhitecube\NovaPage\Pages\Queryon the nova index page. It's intended to mimic theindexQuerymethod.I've also added the method
Whitecube\NovaPage\Pages\Query::sortByto allow simple sorting.It might work better just having a generic callback (e.g.
$query->setCallback(...)) which gets applied to the Collection inWhitecube\NovaPage\Pages\Query::get.Should merge in conjunction with #45mergedCloses
#44 (sorta)
Usage
Configure your own config
novapage.default_page_resourceinconfig/novapage.php