I have this method:
public function getAll( $name = false, $json = false ) {
if ( $name )
$sections = Sections::all()->pluck( 'name' );
else
$sections = Sections::all();
return ( $json ) ? json_encode( $sections ) : $sections;
}
And address for this is: example.com/api/sections/all/{name}/{json}
So i have question for this - how to define address for TRUE parameter?
In my opinion example.com/api/sections/all/true/true
is not good idea because I'm showing parameters types.
What solution do you propose? Or maybe another method construction?
将name
和json
作为query parameters
似乎是合理的,因此您的URL类似于example.com/api/sections/all?name=1&json=1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.