Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.



31.3k
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.phalconphp.com/en/latest/reference/model-relationships.html

and then you will be able to use ORM facilities. Query builder is good too: https://docs.phalconphp.com/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.phalconphp.com/en/latest/reference/routing.html