A Laravel app that implements a JSON API

Ask about general coding issues or problems here.

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 1
Joined: Sat Dec 29, 2018 6:52 am

Sat Dec 29, 2018 7:29 am

I have a task on how to make a laravel app implements a Json API i need some help or guidance how to start with this project

IntroductionHelp HR manager Personia get a grasp of her ever changing company’s hierarchy! Every week Personia receives a JSON of employees and their supervisors from her demanding CEO Chris, who keeps changing his mind about how to structure his company. Chris wants this JSON to be restructured, so that he can better see the employees hierarchy. Chris is especially happy if Personia provides him with a visual graphical representation of the hierarchy.
To make her life easier, Personia wants to have the following:
1- A Laravel app that implements a JSON API
2- Personia would like to post the JSON from Chris to an endpoint of your choice. This JSON represents an Employee -> Supervisor relationship that looks like this:
"Pete": "Nick",
"Barbara": "Nick",
"Nick": "Sophie",
"Sophie": "Jonas"

In this case, Nick is a supervisor of Pete and Barbara, Sophie supervises Nick.
3- As a response to calling the endpoint, Personia would like to have a properly formatted JSON which reflects the employees hierarchy in a way, where the most senior employee is on the top of the JSON nested dictionary, and his supervisors are on the bottom. For instance, previous input would result in:
{“Jonas" : [
{“Sophie": [
{“Nick" : [
{"Pete": []},
{"Barbara": []}

4. We assume that the employee names are unique and the input hierarchy is valid. This means, there is always one boss on the top and the hierarchy does not contain loops (unless you would like to do a Bonus bullet point)
5. Don’t forget to Unit test the solution (with e.g. PHPUnit), so that Personia is sure everything works as she has specified

php-forum Fan User
php-forum Fan User
Posts: 600
Joined: Fri Apr 01, 2016 2:18 am

Sun Dec 30, 2018 5:56 am

Step 1: Download Laravel.

Post Reply