0

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?

Damian
  • 525
  • 2
  • 11
  • 24

1 Answers1

0

It seems reasonable to have name and json as query parameters, so your URL becomes something like example.com/api/sections/all?name=1&json=1

volatilevar
  • 1,626
  • 14
  • 16