We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Advanced dynamic crud

Hi,

I have two differents crud :

  • OrganizationResource::crud('/organization'))
  • OrganizationMemberResource::crud('/organization/member'))

I would like to know what is the best way to do :

  • /organization/{id}/member/ in order to get all the member in one Organization.

What I've done so far was coding it manually. Is there a way to do it without having to code it manually ?

Thanks,

edited Oct '16

What you mean by manually ?

You can as well use query params. Create some helper for building conditions and bind from query params and that's it.



43.9k
Accepted
answer
edited Oct '16

Hi,

I understand that a member belongs to an organisation (or maybe to many organisations). Did you set proper relationships ? If not see here https://docs.phalcon.io/en/latest/reference/model-relationships.html

and then you will be able to use ORM facilities. Query builder is good too: https://docs.phalcon.io/en/latest/reference/phql.html#creating-queries-using-the-query-builder

for managing such url /organization/{id}/member/ , router component will do the trick : https://docs.phalcon.io/en/latest/reference/routing.html