mevdschee / mevdschee/php-crud-api

One To Many Relation output an array

Open
#90 4 comments 0 reactions 1 assignee View on GitHub

@mevdschee is already working on this.

Since Jul 13, 2016.

enhancement
Dominant language
PHP
Stars
3.7k
Forks
1k
Avg merge
1h 55m
Merged PRs (30d)
7

Description

Hi

I have the folowing database :
sections

and I am trying to get the sections with their corresponding department and directorate, the output is the following

{
  "sections": [
    {
      "ID": "1",
      "NAME": "section1",
      "DEPARTMENT_ID": "1",
      "departments": [
        {
          "ID": "1",
          "NAME": "depart 1",
          "DIRECTORATE_ID": "1",
          "directorates": [
            {
              "ID": "1",
              "NAME": "directorate1",
              "PHONE_NUMBER": "123",
              "ROOM_NUMBER": "123"
            }
          ],
          "EDL_ID": "65",
          "PHONE_NUMBER": "659",
          "ROOM_NUMBER": "987"
        }
      ],
      "PHONE_NUMBER": "654",
      "ROOM_NUMBER": "865"
    }
  ]
}

I think it will be better if the departments returned for the section is not an array, it can be directly the department object? a section has a department. and the same for the directorate in the department.

What do you think about this?

Thank you

test.txt

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.