dongyan7172
2017-06-13 19:46
浏览 185
已采纳

Laravel - 加载视图 - >获取空白页面问题

This is my class

class PageController extends Controller
{
    public function show($slug = null, $slug2 = null)
    {
        if (!$slug2) { 
            $cat1 = 1;
            return view('frontend/pages/category', [
               'categories' => $cat1
            ]);
        }
    }
}

This version of the code is working fine. If I move the return view logic into a separate function like this:

        class PageController extends Controller
        {

                public function show($slug = null, $slug2 = null)
                {
                    if (!$slug2) { 
                        $cat1 = 1;
                        $this->myfunction($cat1);
                    }
                }
                public function myfunction($cat1)
                {
                        return view('frontend/pages/category', [
                           'categories' => $cat1
                        ]);
                }
         }

I'm getting a blank page. Nothing in the logs. Any idea why ?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • douzi1117 2017-06-13 19:48
    最佳回答

    You should return the result of myfunction inside show

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题