<?php namespace TPS\Birzha\Components;

use Cms\Classes\ComponentBase;
use TPS\Birzha\Models\BirzhaDoc;
use RainLab\Translate\Classes\Translator;

class Birzhadocs extends ComponentBase
{
    public function componentDetails() {
        return [
            'name' => 'Docs list',
            'description' => 'List of docs'
        ];
    }

    public function onRun() {
        $this->sections_with_docs = $this->loadDocs();
    }

    protected function loadDocs() {
        $translator = Translator::instance();

        return BirzhaDoc::where('lang', $translator->getLocale())->get();
    }

    public $sections_with_docs;
}
