File: D:/HostingSpaces/SBogers10/netwerkbrabant.komma.pro/app/KommaApp/Tags/Models/Tag.php
<?php
/**
*
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
namespace App\KommaApp\Tags\Models;
use App\KommaApp\Kms\Core\Entities\DisplayNameTrait;
use App\KommaApp\Events\Models\Event;
use App\KommaApp\Kms\Core\AbstractTranslatableModel;
use App\KommaApp\Languages\Models\Language;
use App\KommaApp\MagazineArticles\Models\MagazineArticle;
use App\KommaApp\NewsArticles\Models\NewsArticle;
use App\KommaApp\PastEvents\Models\PastEvent;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* Class Tag
*
* @package App\KommaApp\Regions\Models
* @property string $name
* @property \Carbon\Carbon|null $created_at
* @property \Carbon\Carbon|null $updated_at
*/
class Tag extends AbstractTranslatableModel
{
use DisplayNameTrait;
protected $table = 'tags';
protected $class = Tag::class;
/*
* Transient properties on Eloquent models
* These are not saved to database.
*/
public $thumbnail = false;
/**
* Gets the translation models for this model
*
* @return HasMany that resolves to AbstractTranslationModel instances
*/
public function translations(): HasMany
{
return $this->hasMany(TagTranslation::class);
}
public function languages(): BelongsToMany
{
return $this->belongsToMany(Language::class, 'tag_translations')
->withPivot('name')
->withTimestamps();
}
/**
* Get all of the events that are assigned this tag.
*/
public function events()
{
return $this->morphedByMany(Event::class, 'taggable');
}
/**
* Get all of the past events that are assigned this tag.
*/
public function pastEvents()
{
return $this->morphedByMany(PastEvent::class, 'taggable');
}
/**
* Get all of the magazine articles that are assigned this tag.
*/
public function magazineArticles()
{
return $this->morphedByMany(MagazineArticle::class, 'taggable');
}
/**
* Get all of the magazine articles that are assigned this tag.
*/
public function newsArticles()
{
return $this->morphedByMany(NewsArticle::class, 'taggable');
}
}