dimanche 11 février 2018

Laravel 5.5 - Show specific category from API response

I am returning an API response inside a Categories controller in Laravel 5.5 like this...

public function get(Request $request) {

   $categories = Category::all();

   return Response::json(array(
    'error' => false,
    'categories_data' => $categories,
  ));

}

Now I am trying to also have the option to return a specific category, how can I do this as I am already using the get request in this controller?

Do I need to create a new route or can I modify this one to return a specific category only if an ID is supplied, if not then it returns all?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire