<?php

namespace App\Http\Controllers;


use App\Models\Category;
use App\Models\Leader;

class LeaderController extends Controller
{
    public $category_id = 29;


    public function index()
    {
        $category = Category::find($this->category_id);

        $parent  = $category;
        $topCate = $category->getTopCategory();

        if ($category->childrens->isEmpty() && $category->parent) {
            $parent = $category->parent;
        }

        $leaders = Leader::shown()->latest()->get();

        $data = [
            'leaders'  => $leaders,
            'category' => $category,
            'parent'   => $parent,
            'topCate'  => $topCate,
        ];

        return view('leader.index', $data);
    }


}
