© Paul Redmond 2016

Paul Redmond, Lumen Programming Guide, 10.1007/978-1-4842-2187-7_12

12. Ratings

Paul Redmond

(1)Phoenix, Arizona, USA

The final chapter will focus on adding the ability to rate things. When you think of ratings, you might think of book ratings, but actually you can apply ratings to multiple things. Specifically, you will add ratings to authors. Using Eloquent makes it easy to apply data like ratings to multiple models (as you will see shortly) using polymorphic relationships ( https://laravel.com/docs/5.2/eloquent-relationships#polymorphic-relations ). Polymorphic relationships allow a model (ratings) to belong to more than one model. In the context of your API, ratings make sense for authors, books, and bundles.

Your ratings ...

Get Lumen Programming Guide: Writing PHP Microservices, REST and Web Service APIs now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.