Файл: app/Models/Board.php
Строк: 44
<?php
declare(strict_types=1);
namespace AppModels;
use AppTraitsCategoryTreeTrait;
use AppTraitsUploadTrait;
use IlluminateDatabaseEloquentCollection;
use IlluminateDatabaseEloquentRelationsBelongsTo;
use IlluminateDatabaseEloquentRelationsHasMany;
/**
* Class Board
*
* @property int id
* @property int sort
* @property int parent_id
* @property string name
* @property int count_items
* @property int closed
* @property Collection children
* @property Board parent
*/
class Board extends BaseModel
{
use CategoryTreeTrait;
use UploadTrait;
/**
* Indicates if the model should be timestamped.
*/
public $timestamps = false;
/**
* The attributes that aren't mass assignable.
*/
protected $guarded = [];
/**
* Директория загрузки файлов
*/
public string $uploadPath = 'uploads/boards';
/**
* Возвращает связь родительской категории
*/
public function parent(): BelongsTo
{
return $this->belongsTo(self::class, 'parent_id')->withDefault();
}
/**
* Возвращает связь подкатегорий
*/
public function children(): HasMany
{
return $this->hasMany(self::class, 'parent_id')->orderBy('sort');
}
}