File: D:/HostingSpaces/SBogers10/ehboledensysteem.komma.pro/app/KommaApp/Posts/Models/Post.php
<?php
/**
*
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma
*/
namespace App\KommaApp\Posts\Models;
use App\KommaApp\Documents\DocumentsTrait;
use App\KommaApp\Documents\Kms\DocumentableInterface;
use App\KommaApp\Kms\Core\AbstractTranslatableModel;
use App\KommaApp\Languages\Models\Language;
use App\KommaApp\Sites\HasSitesInterface;
use App\KommaApp\Sites\Models\Site;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
/**
* Class Page
*
* @package App\KommaApp\Pages\Models
* @property int site_id
* @property int lft
* @property int rgt
* @property int tree
* @property-read \Carbon $date
* @property-read \Illuminate\Database\Eloquent\Collection|\App\KommaApp\Languages\Models\Language[] $languages
* @property-read \Illuminate\Database\Eloquent\Collection|\App\KommaApp\Sites\Models\Site[] $sites
* @property-read \App\KommaApp\Posts\Models\PostTranslation $translation
* @property-read \Illuminate\Database\Eloquent\Collection|\App\KommaApp\Posts\Models\PostTranslation[] $translations
* @mixin \Eloquent
* @property int $id
* @property int $active
* @property \Carbon\Carbon|null $created_at
* @property \Carbon\Carbon|null $updated_at
* @method static \Illuminate\Database\Eloquent\Builder|\App\KommaApp\Posts\Models\Post whereActive($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\KommaApp\Posts\Models\Post whereCreatedAt($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\KommaApp\Posts\Models\Post whereDate($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\KommaApp\Posts\Models\Post whereId($value)
* @method static \Illuminate\Database\Eloquent\Builder|\App\KommaApp\Posts\Models\Post whereUpdatedAt($value)
* @property-read \Illuminate\Database\Eloquent\Collection|\App\KommaApp\Documents\Models\Document[] $documents
* @property-read \Illuminate\Database\Eloquent\Collection|\App\KommaApp\Documents\Models\Document[] $images
*/
class Post extends AbstractTranslatableModel implements HasSitesInterface, DocumentableInterface
{
use DocumentsTrait;
protected $table = 'posts';
protected $class = Post::class;
/*
* Transient properties on Eloquent models
* These are not saved to database.
*/
public $thumbnail = false;
protected $fillable = ['active', 'date', 'site_id'];
protected $dates = ['date'];
/**
* Gets the translation models for this model
*
* @return HasMany that resolves to AbstractTranslationModel instances
*/
public function translations(): HasMany
{
return $this->hasMany(PostTranslation::class);
}
public function languages(): BelongsToMany
{
return $this->belongsToMany(Language::class, 'post_translations')
->withPivot('slug', 'name', 'description')
->withTimestamps();
}
/**
* Get the site or sites for this model
*
* @return BelongsToMany
*/
public function sites(): BelongsToMany
{
return $this->belongsToMany(Site::class);
}
public function __get($key)
{
if($key == "title") {
if($this->translation) {
return $this->translation->name;
}
}
return parent::__get($key);
}
}