2022-02-09 21:40:16 +01:00
|
|
|
<?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';
|
|
|
|
|
2022-06-30 03:26:35 +02:00
|
|
|
private static $db = [
|
|
|
|
'Name' => 'Varchar',
|
|
|
|
];
|
|
|
|
|
2022-02-09 21:40:16 +01:00
|
|
|
private static $has_one = [
|
|
|
|
'Customer' => Customer::class,
|
|
|
|
'ShippingAddress' => Address::class,
|
|
|
|
];
|
|
|
|
|
|
|
|
private static $searchable_fields = [
|
|
|
|
'CustomFirstName' => [
|
|
|
|
'title' => 'First Name',
|
2022-06-30 03:26:35 +02:00
|
|
|
'field' => TextField::class,
|
|
|
|
'match_any' => [
|
|
|
|
// Searching with the "First Name" field will show Orders matching either Name, Customer.FirstName, or ShippingAddress.FirstName
|
|
|
|
'Name',
|
|
|
|
'Customer.FirstName',
|
|
|
|
'ShippingAddress.FirstName',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'PartialMatchField' => [
|
2022-02-09 21:40:16 +01:00
|
|
|
'field' => TextField::class,
|
|
|
|
'filter' => 'PartialMatchFilter',
|
|
|
|
'match_any' => [
|
2022-06-30 03:26:35 +02:00
|
|
|
'Name',
|
|
|
|
'Customer.FirstName',
|
|
|
|
'ShippingAddress.FirstName',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'ExactMatchField' => [
|
|
|
|
'field' => TextField::class,
|
|
|
|
'filter' => 'ExactMatchFilter',
|
|
|
|
'match_any' => [
|
|
|
|
'Name',
|
2022-02-09 21:40:16 +01:00
|
|
|
'Customer.FirstName',
|
|
|
|
'ShippingAddress.FirstName',
|
2022-06-30 03:26:35 +02:00
|
|
|
],
|
|
|
|
],
|
2022-02-09 21:40:16 +01:00
|
|
|
];
|
|
|
|
}
|