<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Encore\Admin\Traits\AdminBuilder;
use Encore\Admin\Traits\ModelTree;

class Category extends Model
{
    use ModelTree, AdminBuilder;

    public static function byIdGetChild($id)
    {
        return self::where('parent_id', $id)->pluck('title', 'id');
    }

    public static function getRoot()
    {
        return self::where('root', 'T')->pluck('title', 'id');
    }

    public static function byId($id)
    {
        return self::where('id', $id)->first();
    }
}
