hasMany(Order::className(), ['customer_id' => 'id'])->orderBy('created_at'); } public function afterSave($insert) { ActiveRecordTest::$afterSaveInsert = $insert; ActiveRecordTest::$afterSaveNewRecord = $this->isNewRecord; parent::afterSave($insert); } /** * sets up the index for this record * @param Command $command * @param boolean $statusIsBoolean */ public static function setUpMapping($command, $statusIsBoolean = false) { $command->deleteMapping(static::index(), static::type()); $command->setMapping(static::index(), static::type(), [ static::type() => [ "_id" => ["path" => "id", "index" => "not_analyzed", "store" => "yes"], "properties" => [ "name" => ["type" => "string", "index" => "not_analyzed"], "email" => ["type" => "string", "index" => "not_analyzed"], "address" => ["type" => "string", "index" => "analyzed"], "status" => $statusIsBoolean ? ["type" => "boolean"] : ["type" => "integer"], ] ] ]); } public static function createQuery() { return new CustomerQuery(get_called_class()); } }