File: D:/HostingSpaces/SBogers10/vebon.komma.pro/app/KommaApp/Pages/Models/Page.php
<?php
/**
*
*
* @author Komma <info@komma.pro>
* @copyright (c) 2012-2016, Komma Mediadesign
*/
namespace KommaApp\Pages\Models;
use KommaApp\Kms\Core\NestedSets\Nodes\EloquentNode as NestedSetNode;
class Page extends NestedSetNode
{
protected $table = 'pages';
/*
* Transient properties on Eloquent models
* These are not saved to database.
*/
public $thumbnail = false;
public $images = false;
public $parent_id = false;
public $title = false;
protected $fillable = ['active', 'controller', 'searchable', 'site_id', 'lft', 'rgt', 'tree', 'code_name', 'call_to_action'];
public function site()
{
return $this->belongsTo(\KommaApp\Sites\Models\Site::class);
}
public function translations()
{
return $this->hasMany(\KommaApp\Pages\Models\PageTranslation::class);
}
public function languages()
{
return $this->belongsToMany(\KommaApp\Languages\Models\Language::class, 'page_translations')
->withPivot('slug', 'name', 'description')
->withTimestamps();
}
public function getParentId()
{
if ($this->getDepth() == 0) {
// Node is root node
return 0;
}
return $this->getParent()->id;
}
}