protected $_cast = false;
protected $_translatable = false;
+ protected $_elastic = false;
+ protected $_elasticType = 'string';
+ protected $_elasticAnalyser = 'standard';
+
/**
* @var CubistMagicAbstractModel
*/
return ['type' => $this->_adminType, 'view_namespace' => $this->_viewNamespace, 'column' => false, 'form' => 'both', 'rules' => '',
'fillable' => true, 'guarded' => false, 'hidden' => false, 'translatable' => $this->_translatable,
'column_type' => $this->_columnType, 'default' => '', 'cast' => $this->_cast, 'column_view_namespace' => $this->_columnViewNamespace, 'searchLogic' => $this->_searchLogic,
+ 'elastic' => $this->_elastic, 'elastic_type' => $this->_elasticType, 'elastic_analyser' => $this->_elasticAnalyser,
'allow_null' => true,
- 'fake' => false, 'store_in' => 'extras', 'attributes' => [],];
+ 'fake' => false, 'store_in' => 'extras', 'attributes' => []];
}
public function __construct($attributes)
}
}
+ public function getElasticMapping()
+ {
+ if (!$this->getAttribute('elastic', false)) {
+ return [];
+ }
+ return [$this->getAttribute('name') =>
+ [
+ 'type' => $this->getAttribute('elastic_type'),
+ 'analyser' => $this->getAttribute('elastic_analyser')
+ ]
+ ];
+ }
+
/**
* @return null|string
*/
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
use Spatie\MediaLibrary\Models\Media;
use Venturecraft\Revisionable\RevisionableTrait;
+use Elasticquent\ElasticquentTrait;
class CubistMagicAbstractModel extends Model implements HasMedia
{
use BunchOfFields {
addField as protected bunchAddField;
}
+ use ElasticquentTrait;
protected static $_doctrineTypesMapping = ['int' => 'integer'];
*/
protected $varSetBeforeOperations = [];
+ /**
+ * @var array
+ */
+ protected $mappingProperties = [];
+
public static function boot()
{
parent::boot();
$this->translatable[] = $name;
}
}
+
+ $this->mappingProperties += $field->getElasticMapping();
+
return $field;
}
$this->addField(['name' => 'title',
'label' => 'Titre',
'type' => 'Text',
- 'column' => true]);
+ 'column' => true,
+ 'elastic' => true,]);
$this->addField(['name' => 'slug',
'type' => 'Slug',
'type' => 'Text',
'label' => 'Lieu de l\'événement',
'when' => ['type' => ['event']],
+ 'elastic' => true,
]);
$this->addField(['name' => 'chapo',
'type' => 'Textarea',
'label' => 'Chapo',
'hint' => 'Texte court affiché sur le listing des actualités',
- 'when' => ['type' => ['news']]
+ 'when' => ['type' => ['news']],
+ 'elastic' => true,
]);
$this->addField(['name' => 'image',
$this->addField(['name' => 'content',
'type' => 'Markdown',
- 'label' => 'Contenu'
+ 'label' => 'Contenu',
+ 'elastic' => true,
]);
$this->addField(['name' => 'status',