78 lines
1.6 KiB
PHP
78 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Models\Content;
|
|
|
|
use App\Models\FileManager\File;
|
|
use App\Models\User;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Modules\Categories\Entities\Category;
|
|
|
|
/**
|
|
* Class Content
|
|
*/
|
|
class Content extends Model
|
|
{
|
|
use SoftDeletes, ModelTraits\Content;
|
|
public $timestamps = true;
|
|
protected $fillable = [
|
|
'user_id',
|
|
'parent_id',
|
|
'category_id',
|
|
'language',
|
|
'module_handler',
|
|
'published_from',
|
|
'published_to',
|
|
'title_photo',
|
|
'template',
|
|
'is_homepage',
|
|
'title',
|
|
'url',
|
|
'meta_keywords',
|
|
'meta_description',
|
|
'content',
|
|
'module_settings',
|
|
'status'
|
|
];
|
|
|
|
/**
|
|
* Mark relationship with its historical records
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\HasMany
|
|
*/
|
|
public function history()
|
|
{
|
|
return $this->hasMany(ContentHistory::class);
|
|
}
|
|
|
|
/**
|
|
* Mark relationship with users table
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function author()
|
|
{
|
|
return $this->belongsTo(User::class, 'user_id');
|
|
}
|
|
|
|
/**
|
|
* Related files to content page
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany
|
|
*/
|
|
public function files()
|
|
{
|
|
return $this->belongsToMany(File::class, 'contents_has_files');
|
|
}
|
|
|
|
/**
|
|
* Category of content page
|
|
*
|
|
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
|
|
*/
|
|
public function category()
|
|
{
|
|
return $this->belongsTo(Category::class);
|
|
}
|
|
}
|