1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?php
namespace yiiunit\data\ar\elasticsearch;
use yii\elasticsearch\Command;
/**
* Class OrderItem
*
* @property integer $order_id
* @property integer $item_id
* @property integer $quantity
* @property string $subtotal
*/
class OrderItem extends ActiveRecord
{
public function attributes()
{
return ['order_id', 'item_id', 'quantity', 'subtotal'];
}
public function getOrder()
{
return $this->hasOne(Order::className(), ['id' => 'order_id']);
}
public function getItem()
{
return $this->hasOne(Item::className(), ['id' => 'item_id']);
}
/**
* sets up the index for this record
* @param Command $command
*/
public static function setUpMapping($command)
{
$command->deleteMapping(static::index(), static::type());
$command->setMapping(static::index(), static::type(), [
static::type() => [
"properties" => [
"order_id" => ["type" => "integer"],
"item_id" => ["type" => "integer"],
"quantity" => ["type" => "integer"],
"subtotal" => ["type" => "integer"],
]
]
]);
}
}