silverstripe-framework/tests/php/ORM/Search/SearchContextTest/Order.php
Tyler Trout 6b1c5eb6d7
NEW Allow methods to be used for flexible searchable_fields (#10199)
* Allow methods to be used for flexible searchable_fields

* match_any key

* Documentation

* Update docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md

Co-authored-by: GuySartorelli <36352093+GuySartorelli@users.noreply.github.com>

* Search fields test

* Newlines

* Update src/ORM/Search/SearchContext.php

Co-authored-by: Steve Boyd <emteknetnz@gmail.com>

* Update docs/en/02_Developer_Guides/00_Model/11_Scaffolding.md

Co-authored-by: Steve Boyd <emteknetnz@gmail.com>

* Removed comments and whitespace. Linting fixes

Co-authored-by: GuySartorelli <36352093+GuySartorelli@users.noreply.github.com>
Co-authored-by: Steve Boyd <emteknetnz@gmail.com>
2022-02-10 09:40:16 +13:00

31 lines
850 B
PHP

<?php
namespace SilverStripe\ORM\Tests\Search\SearchContextTest;
use SilverStripe\Dev\TestOnly;
use SilverStripe\Forms\TextField;
use SilverStripe\ORM\DataObject;
class Order extends DataObject implements TestOnly
{
private static $table_name = 'SearchContextTest_Order';
private static $has_one = [
'Customer' => Customer::class,
'ShippingAddress' => Address::class,
];
private static $searchable_fields = [
'CustomFirstName' => [
'title' => 'First Name',
'field' => TextField::class,
'filter' => 'PartialMatchFilter',
'match_any' => [
// Searching with "First Name" will show Orders with matching Customer or Address names
'Customer.FirstName',
'ShippingAddress.FirstName',
]
]
];
}