doutu4335
doutu4335
2019-02-27 09:08

Laravel在同一个控制器中显示多个功能

  • laravel
  • php

i have a problem with making a newswebsite. I have multiple index functions to load in category views. inside of each view i want to be able to go to an article page by using the show function. how do i use multiple show functions within one controller.

these are 2 of the 8 index funtions i use.

public function indexbusiness()
{
    $artikels =  Artikel::where('category_id', '4')->get();
    return view('pages.business')->with('artikels', $artikels);
}

public function indextech()
{
    $artikels =  Artikel::where('category_id', '5')->get();
    return view('pages.tech')->with('artikels', $artikels);
}

i want to add show functions like this

 public function showbusiness($id)
{
    $artikel = Artikel::find($id);
    return view(pages.show);
}

can someone help me out on this one?

all help is appreciated

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答