recursive function in model doesnt return anything - laravel
<p>I made a function inside <code>category</code> model :</p>

<pre><code>   public function getSecondCategoryByID($category_id = 0,$id = 0)
    {

        $category = $this-&gt;where('id','=',$category_id)-&gt;first();

        if($category-&gt;parent_cat_id == 1)
        {

            $mcategory = $this-&gt;where('id','=',$id)-&gt;first();


            echo 'Inside Model '.$mcategory-&gt;id;
            return $mcategory-&gt;id;


        }else{
            $this-&gt;getSecondCategoryByID($category-&gt;parent_cat_id,$category-&gt;id);
        }

    }
</code></pre>

<p>at a function of controller I called this function :</p>

<pre><code>    $category = new Category;

    $secondCategoryID = $category-&gt;getSecondCategoryByID($category_brand-&gt;category_id,0);

    echo 'After Model   '.$secondCategoryID ;
    return ;
</code></pre>

<p>when I call my function of controller I got this message on page :</p>

<pre><code>Inside Model 3After Model //it should be  Inside Model 3After Model '3'
</code></pre>

<p>I think my model  doesn't return anything ! because after <code>after model</code> is nothing !!!!!</p>