RESTFul API: Hiding fields & creating a new record

Hi All

I have two issues that I need help with

  1. I am developing an API for my application. I’m using /api as a prefix in routes and I’m following various conventions to hide as much as the underlying data as possible and trying to offer the consumer of the data real information. ie no primary of foreign keys. I have a series of “Garments” that are related to “Races” through “GarmentsRaces” relationship.

If I use something like:

$race = $this->Races->find(‘all’, [‘contain’ => [‘Garments’,‘Countries’],‘conditions’ => [‘races.current_url LIKE’ => $slug]]);

I’m finding it difficult to hide/unset some of the data.

  1. I’m trying to submit a new database record (Submissions) via a RESTFul api. I’ve pretty much copy n pasted the controller code from the Admin backend but I’m having difficulty getting the body submitted so that it is compatible with the patchEntity. Database fields are name, filename, email, website, comments. Filename is an actual file.



To hide properties you can set the $_hidden property of your entity -