Topic:: 和 $topic-> 有区别么?
教程里的代码是使用 $topic->
public function index(Request $request, Topic $topic)
{
$topics = $topic->withOrder($request->order)->paginate(20);
return view('topics.index', compact('topics'));
}
我尝试用Topic::
发现效果是一样的
public function index(Request $request)
{
$topics = Topic::withOrder($request->order)->paginate(10);
return view('topics.index', compact('topics'));
}
请问这两种方式有什么区别么?我原先以为Topic::
是类似静态方法的概念,可在使用中发现是一样的
推荐文章: