<?php
namespace App\Models;
class Board extends BaseModel
{
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = false;
/**
* The attributes that aren't mass assignable.
*
* @var array
*/
protected $guarded = [];
/**
* Директория загрузки файлов
*
* @var string
*/
public $uploadPath = UPLOADS . '/boards';
/**
* Возвращает связь родительской категории
*/
public function parent()
{
return $this->belongsTo(self::class, 'parent_id')->withDefault();
}
/**
* Возвращает связь подкатегорий
*/
public function children()
{
return $this->hasMany(self::class, 'parent_id')->orderBy('sort');
}
}