<?php
namespace App\Models;

class Category extends Model {
    protected static function getTable(): string {
        return 'categories';
    }

    public function getParent() {
        if (!$this->parent_slug) {
            return null;
        }
        return self::findBy(['slug' => $this->parent_slug]);
    }

    public function getSubcategories() {
        return self::all(['parent_slug' => $this->slug]);
    }
}
