Child categories different category template

How can I achieve the following with the blade engine.

We have 3 levels of categories. And based in the level the category needs to have a different category template. I found a snippet on stack for classic WP themes. But this doesn’t work with the blade framework (which I’m quit new to).

Below you will find the code. Could you fellow roots friends help me out on this?

// Different template for subcategories
function fkm_subcategory_template( $template ) {
    $cat        = get_queried_object();
    $children   = get_terms( $cat->taxonomy, array(
        'parent'     => $cat->term_id,
        'hide_empty' => false
    ) );

    if( ! $children ) {
        $template = locate_template( 'category-child.php' );
    } elseif( 0 < $cat->category_parent ) {
        $template = locate_template( 'category-grand-child.php' );
    }

    return $template;
}
add_filter( 'category_template', 'fkm_subcategory_template' );

Why? What troubleshooting have you done so far? It looks like you’ve just copy/pasted example code and not modified it at all.

There’s existing threads/info out there on how to render a template with Blade

https://discourse.roots.io/t/manually-render-blade-template-in-functions-php/11292