Yes, Runway does support creating filter presets for Eloquent models. Here's how you can do it:
1. Define the Filter Presets in the Resource Configuration:
In your `config/runway.php` file, you can define the filter presets for each of your Runway resources. For example:
php
'resources' => [
\App\Models\Product::class => [
'name' => 'Products',
'blueprint' => 'product',
'filter_presets' => [
'featured' => [
'filters' => [
'is_featured' => true,
],
'label' => 'Featured Products',
],
'on_sale' => [
'filters' => [
'is_on_sale' => true,
],
'label' => 'On Sale Products',
],
],
],
],
In this example, we've defined two filter presets: "featured" and "on_sale". Each preset has a set of filters and a label that will be displayed in the Statamic Control Panel.
2. Use the Filter Presets in the Runway Tag:
In your Statamic templates, you can use the `filter_preset` parameter with the `< runway:product >` tag to apply the defined filter presets:
html
{{ runway:product filter_preset="featured" }}
<!-- Display the filtered products -->
{{ /runway:product }}
This will apply the "featured" filter preset and display the matching products.
3. Customize the Filter Presets:
You can further customize the filter presets by adding more complex filters, such as range filters, custom scopes, or even combining multiple filters.
php
'filter_presets' => [
'price_range' => [
'filters' => [
'price' => [
'min' => 50,
'max' => 100,
],
],
'label' => 'Price Range: $50 - $100',
],
],
By leveraging filter presets in Runway, you can provide your users with predefined filtering options, making it easier for them to navigate and find the content they're looking for within your Statamic-powered application.
Citations:[1] https://runway.duncanmcclean.com/graphql
[2] https://help.runwayml.com/hc/en-us/articles/15161225169171-Gen-1-advanced-settings
[3] https://shopify.dev/docs/api/shopify-app-remix/v2/guide-graphql-types
[4] https://www.apollographql.com/tutorials/lift-off-part1/09-codegen
[5] https://statamic.com/addons/rad-pack/runway/release-notes