2017-01-07 39 views
0

我有这样的方法:php - 地址中的布尔参数,如何传递给方法?

public function getAll($name = false, $json = false) { 

    if ($name) 
     $sections = Sections::all()->pluck('name'); 
      else 
       $sections = Sections::all(); 


    return ($json) ? json_encode($sections) : $sections; 
} 

和地址是这样的:example.com/api/sections/all/{name}/{json}
所以,我对于这个问题 - 如何为TRUE参数定义的地址?
在我看来example.com/api/sections/all/true/true是不好的主意,因为我显示参数类型。
你提出了什么解决方案?或者也许另一种方法建设?

回答

0

这似乎是合理的有namejsonquery parameters,所以你的URL变得像example.com/api/sections/all?name=1&json=1

相关问题