parent
20c9285b42
commit
e7e3832023
@ -0,0 +1,39 @@
|
||||
# Homework
|
||||
|
||||
Finish [today's labs](../student_labs/)
|
||||
|
||||
As a stretch, once the labs are complete, implement a show route (`find()`) for People (`/people/:id`), Locations (`/locations/:id`), Companies (`/companies/:id`). Each route should return JSON to the client for only the specified person, location, or company in the DB. For example, a call to `/locations/1` would return something like:
|
||||
|
||||
```JSON
|
||||
{
|
||||
"id":1,
|
||||
"street":"123 Fake Street",
|
||||
"city":"Awesometown",
|
||||
"state":"CA"
|
||||
}
|
||||
```
|
||||
|
||||
This is different from the index route we wrote in lecture which returns all specified models in the DB in an array. For example:
|
||||
|
||||
```JSON
|
||||
[
|
||||
{
|
||||
"id":1,
|
||||
"street":"123 Fake Street",
|
||||
"city":"Awesometown",
|
||||
"state":"CA"
|
||||
},
|
||||
{
|
||||
"id":2,
|
||||
"street":"456 Super Circle",
|
||||
"city":"Funton",
|
||||
"state":"NY"
|
||||
},
|
||||
{
|
||||
"id":3,
|
||||
"street":"789 Radical Road",
|
||||
"city":"Coolburg",
|
||||
"state":"PA"
|
||||
}
|
||||
]
|
||||
```
|
||||
@ -0,0 +1,3 @@
|
||||
# Afternoon Lab
|
||||
|
||||
Finish [this morning's lab](morning.md). When complete, implement CREATE, UPDATE, and DELETE functionality on Locations. Once that's complete, implement CREATE, UPDATE, and DELETE functionality on Companies
|
||||
@ -0,0 +1,19 @@
|
||||
# Morning Lab
|
||||
|
||||
Update your code from the lecture this morning so that it has READ (index) functionality for a `Locations` model. The model should have the following attributes (columns):
|
||||
|
||||
1. id (SERIAL)
|
||||
1. street (VARCHAR(32))
|
||||
1. city (VARCHAR(32))
|
||||
1. state (VARCHAR(2))
|
||||
|
||||
It's suggested that you have a php class `Location` that will represent each row in a table called `locations`. This is similar to the `Person` class from the lecture. You can create a "factory" class `Locations` that will be in charge of generating `Location` objects from the DB. This is similar to the `People` class from the lecture.
|
||||
|
||||
If you finish this early, update your code so that it has READ (index) functionality for a `Companies` model. The model should have the following attributes (columns):
|
||||
|
||||
1. id (SERIAL)
|
||||
1. name (VARCHAR(32))
|
||||
1. website (VARCHAR(64))
|
||||
1. industry (VARCHAR(16))
|
||||
|
||||
It's suggested that you have a php class `Company` that will represent each row in a table called `companies`. This is similar to the `Person` class from the lecture. You can create a "factory" class `Companies` that will be in charge of generating `Company` objects from the DB. This is similar to the `People` class from the lecture.
|
||||
Loading…
Reference in new issue