226 lines
5.3 KiB
PHP
226 lines
5.3 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Http\Traits\ElasticTrait;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Elasticquent\ElasticquentTrait;
|
|
|
|
class Media extends Model
|
|
{
|
|
use ElasticquentTrait;
|
|
use ElasticTrait;
|
|
use SoftDeletes;
|
|
protected $with = ["owner", "tags", "etiquette", "articles"];
|
|
protected $table = "medias";
|
|
|
|
/**
|
|
* The elasticsearch settings.
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $indexSettings = [
|
|
'analysis' => [
|
|
'char_filter' => [
|
|
'replace' => [
|
|
'type' => 'mapping',
|
|
'mappings' => [
|
|
'&=> and '
|
|
],
|
|
],
|
|
],
|
|
'filter' => [
|
|
'word_delimiter' => [
|
|
'type' => 'word_delimiter',
|
|
'split_on_numerics' => false,
|
|
'split_on_case_change' => true,
|
|
'generate_word_parts' => true,
|
|
'generate_number_parts' => true,
|
|
'catenate_all' => true,
|
|
'preserve_original' => true,
|
|
'catenate_numbers' => true,
|
|
]
|
|
],
|
|
'analyzer' => [
|
|
'default' => [
|
|
'type' => 'custom',
|
|
'char_filter' => [
|
|
'html_strip',
|
|
'replace',
|
|
],
|
|
'tokenizer' => 'whitespace',
|
|
'filter' => [
|
|
'lowercase',
|
|
'word_delimiter',
|
|
],
|
|
],
|
|
],
|
|
'normalizer' => [
|
|
'my_normalizer' => [
|
|
'type' => 'custom',
|
|
'char_filter' => [],
|
|
'filter' => [
|
|
'lowercase'
|
|
]
|
|
]
|
|
]
|
|
],
|
|
];
|
|
protected $mappingProperties = array(
|
|
'libelle' => array(
|
|
'type' => 'text',
|
|
'analyzer' => 'default',
|
|
'fields' => array(
|
|
'keyword' => array(
|
|
'type' => 'keyword',
|
|
'normalizer' => 'my_normalizer'
|
|
)
|
|
),
|
|
'fielddata' => true
|
|
),
|
|
'created_at' => array(
|
|
'type' => 'text',
|
|
'fielddata' => true
|
|
),
|
|
'updated_at' => array(
|
|
'type' => 'text',
|
|
'fielddata' => true
|
|
),
|
|
'version' => array(
|
|
'type' => 'text',
|
|
'fielddata' => true
|
|
),
|
|
'arcadia_id' => array(
|
|
'type' => 'text',
|
|
'analyzer' => 'standard'
|
|
),
|
|
'articles.noArt' => array(
|
|
'type' => 'text',
|
|
'analyzer' => 'standard'
|
|
),
|
|
'articles.libCcial' => array(
|
|
'type' => 'text',
|
|
'analyzer' => 'default',
|
|
'fields' => array(
|
|
'keyword' => array(
|
|
'type' => 'keyword',
|
|
'normalizer' => 'my_normalizer'
|
|
)
|
|
),
|
|
'fielddata' => true
|
|
)
|
|
);
|
|
|
|
/**
|
|
* Get the dossier that owns the media.
|
|
*/
|
|
public function dossier()
|
|
{
|
|
return $this->belongsTo('App\Models\Dossier', 'dossier_id');
|
|
}
|
|
|
|
/**
|
|
* Get the sujet that owns the media.
|
|
*/
|
|
public function sujet()
|
|
{
|
|
return $this->belongsTo('App\Models\Sujet', 'sujet_id');
|
|
}
|
|
|
|
/**
|
|
* Get the typemedia that owns the media.
|
|
*/
|
|
public function typemedia()
|
|
{
|
|
return $this->belongsTo('App\Models\Typemedia', 'typemedia_id');
|
|
}
|
|
|
|
/**
|
|
* Get the typevue that owns the media.
|
|
*/
|
|
public function typevue()
|
|
{
|
|
return $this->belongsTo('App\Models\Typevue', 'typevue_id');
|
|
}
|
|
|
|
/**
|
|
* Get the langue that owns the media.
|
|
*/
|
|
public function langue()
|
|
{
|
|
return $this->belongsTo('App\Models\Langue', 'typevue_id');
|
|
}
|
|
|
|
/**
|
|
* Get the copyright that owns the media.
|
|
*/
|
|
public function copyright()
|
|
{
|
|
return $this->belongsTo('App\Models\Copyright', 'copyright_id');
|
|
}
|
|
|
|
/**
|
|
* Get the etiquette that owns the media.
|
|
*/
|
|
public function etiquette()
|
|
{
|
|
return $this->belongsTo('App\Models\Etiquette', 'etiquette_id');
|
|
}
|
|
|
|
/**
|
|
* The tag that belong to the media.
|
|
*/
|
|
public function tags()
|
|
{
|
|
return $this->belongsToMany('App\Models\Tag', 'medias_tags', 'media_id', 'tag_id');
|
|
}
|
|
|
|
/**
|
|
* The articles that belong to the media.
|
|
*/
|
|
public function articles()
|
|
{
|
|
return $this->belongsToMany('App\Models\Article', 'medias_articles', 'media_id', 'article_id');
|
|
}
|
|
|
|
/**
|
|
* The societes that belong to the media.
|
|
*/
|
|
public function societes()
|
|
{
|
|
return $this->belongsToMany('App\Models\Societe', 'medias_societes', 'media_id', 'societe_id');
|
|
}
|
|
|
|
/**
|
|
* The marques that belong to the media.
|
|
*/
|
|
public function marques()
|
|
{
|
|
return $this->belongsToMany('App\Models\Marque', 'medias_marques', 'media_id', 'marque_id');
|
|
}
|
|
|
|
/**
|
|
* Get the user that owns the media.
|
|
*/
|
|
public function owner()
|
|
{
|
|
return $this->belongsTo('App\User', 'created_by');
|
|
}
|
|
|
|
/**
|
|
* Get the historiques for the media.
|
|
*/
|
|
public function historiques()
|
|
{
|
|
return $this->hasMany('App\Models\Historique');
|
|
}
|
|
|
|
/**
|
|
* The paniers that belong to the media.
|
|
*/
|
|
public function paniers()
|
|
{
|
|
return $this->belongsToMany('App\Models\Panier', 'paniers_medias', 'media_id', 'panier_id');
|
|
}
|
|
}
|