Exercise Wednesday

Goal: Spend some time (two days) working on building out an application with two models and saving information for that application in the database. By the time you are done, you should feel very familiar with CRUD functionality and adapting your Silex applications to use all of the methods you have created with the database.

Code


Best Restaurants

Create a website where users can add their favorite restaurants by the type of cuisine they offer. Make sure you have passing tests for all of your methods before you integrate them into your Silex app.

  • Add a Cuisine class. Build out all CRUD functionality (Create, Read, Update, Delete) for this class. Remember that "Read" means to view a particular cuisine and to list out all of the cuisines.
  • Add a Restaurant class. Build out all CRUD functionality for this class.
  • Add properties other than name to your Restaurant class, so that you can display descriptive information about the restaurants.
  • Make the connection between a cuisine and a restaurant in the database. A cuisine can have many restaurants, but a restaurant can only be attached to one cuisine. Hint: create a cuisine_id in one of your classes.
  • Allow a user to search for all of a cuisine's restaurants.

If you make it this far, great job! You have practiced everything we wanted you to practice. If you have time, go ahead and tackle the next few features.

  • Now your application allows for users to review restaurants. Build out a Review class and make the relationship in the database, so that a restaurant has many reviews. Pretend that the users who are reviewing the website are different from the user who added the restaurant.
  • Display all of the reviews at the bottom of the restaurant's page. *Style your application using Bootstrap.